Maven Model Builder

The effective model builder, with inheritance, profile activation, 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, with optional plugin processing:

  • phase 1
    • profile activation
    • model normalization
    • profile injection
    • parent resolution until super-pom
    • inheritance assembly
    • model interpolation (see below)
    • url normalization
  • phase 2
    • model path translation
    • plugin management injection
    • (optional) lifecycle bindings injection
    • dependency management import (for dependencies of type pom in the <dependencyManagement> section)
    • dependency management injection
    • (optional) reports configuration
    • (optional) reports conversion to decoupled site plugin
    • (optional) plugins configuration
    • effective model validation

Model Interpolation

Model Interpolation consists in replacing ${...} with calculated value. It is done in StringSearchModelInterpolator (javadoc, source).

Values are evaluated in sequence from different syntaxes:

valueevaluation resultcommon examples
project.* 
pom.* (deprecated
* (deprecated)
POM content (see POM reference)${project.version} 
${project.build.finalName} 
${project.build.artifactId} 
${project.build.directory}
basedir 
project.basedir 
pom.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}
build.timestamp 
maven.build.timestamp
the timestamp of build start, in yyyyMMdd-HHmm 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.homeThe path to the current Maven home.${maven.home}
maven.versionThe version number of the current Maven execution (since 3.0.4). For example, "3.0.3".${maven.version}
maven.build.versionThe full build version of the current Maven execution (since 3.0.4). For example, "Apache Maven 3.0.3 (r1075438; 2011-02-28 11:31:09-0600)".${maven.build.version}
*Java system properties (see JDK reference)${user.home} 
${java.home}
env.* 
*
environment variables${env.PATH}
settings.*Local user settings (see settings reference)${settings.localRepository}

Notice that after model interpolation, ${...} 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.