The effective model builder, with profile activation, inheritance, interpolation, ...
The main component is ModelBuilder
(javadoc, source), with its DefaultModelBuilder
implementation (javadoc, source) that manages the steps sequence.
The sequence is divided into 2 phases:
${basedir}
(since Maven 3), ${rootDirectory}
(since Maven 4), system properties and user propertiesModelValidator
(javadoc), with its DefaultModelValidator
implementation (source)ModelValidator
(javadoc), with its DefaultModelValidator
implementation (source)ModelNormalizer
(javadoc), with its DefaultModelNormalizer
implementation (source)ProfileInjector
(javadoc), with its DefaultProfileInjector
implementation (source)UrlNormalizer
(javadoc), with its DefaultUrlNormalizer
implementation (source)ModelPathTranslator
(javadoc), with its DefaultModelPathTranslator
implementation (source)PluginManagementInjector
(javadoc), with its DefaultPluginManagementInjector
implementation (source)LifecycleBindingsInjector
(javadoc), with its DefaultLifecycleBindingsInjector
implementation in maven-core (source)pom
and scope import
in the <dependencyManagement>
section)DependencyManagementInjector
(javadoc), with its DefaultDependencyManagementInjector
implementation (source)ModelNormalizer
(javadoc), with its DefaultModelNormalizer
implementation (source)ReportConfigurationExpander
(javadoc), with its DefaultReportConfigurationExpander
implementation (source)ReportingConverter
(javadoc), with its DefaultReportingConverter
implementation (source)PluginConfigurationExpander
(javadoc), with its DefaultPluginConfigurationExpander
implementation (source)ModelValidator
(javadoc), with its DefaultModelValidator
implementation (source)Inheritance Assembly consists in filling current model empty fields with values taken from parent model. It is done in InheritanceAssembler
(javadoc), with its DefaultInheritanceAssembler
implementation (source).
By default, every model field is inherited as-is from parent, with a few exceptions that are intentionally not inherited: modelVersion
, artifactId
, profiles
(injected in phase 1) and prerequisites
.
Notice that the 5 URLs from the model (project.url
, project.scm.connection
, project.scm.developerConnection
, project.scm.url
and project.distributionManagement.site.url
) have a special inheritance handling:
project.directory
POM property value is defined, it is used instead of artifact id: this permits default inheritance calculations when module directory name is not equal to artifact id. Notice that this property is not inherited from a POM to its child: child's POM will use child artifact id if property is not set.false
for each url: project/@child.project.url.inherit.append.path
, project/distributionManagement/site/@child.site.url.inherit.append.path
, project/scm/@child.scm.connection.inherit.append.path
, project/scm/@child.scm.developerConnection.inherit.append.path
and project/scm/@child.scm.url.inherit.append.path
.Model Interpolation consists in replacing ${...}
with calculated value. It is done in StringVisitorModelInterpolator
(javadoc, source).
Notice that model interpolation happens after profile activation, and that profile activation doesn't benefit from every values: interpolation for file-based activation is limited to ${basedir}
(which was introduced in Maven 3 and is not deprecated in this context) and ${rootDirectory}
(introduced in Maven 4), system properties and user properties.
Values are evaluated in sequence from different syntaxes:
value | evaluation result | common examples |
---|---|---|
project.* pom.* (deprecated) * (deprecated) |
POM content (see POM reference) | ${project.version} ${project.build.finalName} ${project.artifactId} ${project.build.directory} |
project.basedir pom.basedir (deprecated) basedir (deprecated) |
the directory containing the pom.xml file |
${project.basedir} |
project.baseUri pom.baseUri (deprecated) |
the directory containing the pom.xml file as URI |
${project.baseUri} |
project.rootDirectory |
the project's root directory (containing a .mvn directory or with the root="true" xml attribute) |
${project.rootDirectory} |
build.timestamp maven.build.timestamp |
the UTC timestamp of build start, in yyyy-MM-dd'T'HH:mm:ss'Z' default format, which can be overridden with maven.build.timestamp.format POM property |
${maven.build.timestamp} |
* |
user properties, set from CLI with -Dproperty=value |
${skipTests} |
* |
model properties, such as project properties set in the pom | ${any.key} |
maven.home |
The path to the current Maven home. | ${maven.home} |
maven.version |
The version number of the current Maven execution (since 3.0.4). For example, "3.0.5 ". |
${maven.version} |
maven.build.version |
The full build version of the current Maven execution (since 3.0.4). For example, "Apache Maven 3.2.2 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19T14:51:28+01:00) ". |
${maven.build.version} |
maven.repo.local |
The repository on the local machine Maven shall use to store installed and downloaded artifacts (POMs, JARs, etc). | ${user.home}/.m2/repository |
* |
Java system properties (see JDK reference) | ${user.home} ${java.home} |
* |
User properties | ${foo} |
env.* * |
environment variables | ${env.PATH} |
settings.* |
Local user settings (see settings reference) | ${settings.localRepository} |
changelist revision sha1 |
CI friendly placeholders for the project version (see Maven CI Friendly Versions) | 1.0.0-${changelist}-SNAPSHOT |
${...}
content can remain in the model that will be evaluated later when setting plugin parameters. This happens in particular with settings.*
values for Settings Model,${project.build.sourceEncoding}
for source files encoding (defaults to UTF-8
since Maven 4.0.0, no default value was provided in Maven 3.x, meaning that the platform encoding was used by plugins)${project.reporting.outputEncoding}
for reporting output files encoding (defaults to UTF-8
since Maven 4.0.0, no default value was provided in Maven 3.x, plugins usually defaulting to UTF-8
)