We have a lifecycle mapping for the packaging of *jar* below. You see that for this packaging we have a *default* lifecycle and a list of phases where each phase is a comma separated list of goals to run and they are in the form groupId:artifactId:version.
default
org.apache.maven.plugins:maven-resources-plugin:resources
org.apache.maven.plugins:maven-compiler-plugin:compile
org.apache.maven.plugins:maven-resources-plugin:testResources
org.apache.maven.plugins:maven-compiler-plugin:testCompile
org.apache.maven.plugins:maven-surefire-plugin:test
org.apache.maven.plugins:maven-jar-plugin:jar
org.apache.maven.plugins:maven-install-plugin:install
org.apache.maven.plugins:maven-deploy-plugin:deploy
We need to turn this list of phases into a set of plugin objects that have an xml representation like the following:
org.apache.maven.plugins
maven-resources-plugin
process
.
.
.
We need this form so that the model builder can make the first pass at merging. Full merging cannot be done because we don't know what the version of the plugin is yet that the user has requested. For plugins in the default lifecycle they are typically defined in the plugin management section of the parent POM. When the merging is complete we are going to have something that looks like the following:
org.apache.maven.plugins
maven-resources-plugin
1.0
process
.
.
.
Once we have the version of the plugins the appropriate call to the plugin manager can be made to get the MojoDescriptor for the goal that needs to be run. In the MojoDescriptor we are interested in the element and element. From these elements we need to make a component configuration for the MojoExecution. The actual DOM like structure we create is of type PlexusConfiguration and is the type we use with the ComponentConfigurator to initialize fields in a Plexus component. Typically this is done within Plexus with the configuration supplied with component configuration, but in Maven we take configuration values from the POM. So we have to use the ComponentConfigurator outside of Plexus in order to configurure the Maven Mojo which is just a Plexus component. We can use the information from the MojoDescriptor along with the merged configuration information that is now present in the POM to create the complete PlexusConfiguration used to populate values in the Maven Mojo.
foreach configuration element:
- if read only and being set squawk
- find the parameter
- get value from expression or default
- if required and null squawk
${localRepository}
${project.resources}
${project.repositories}
${project.remoteArtifactRepositories}
${basedir}/src/main/appended-resources
${excludeScope}
${includeScope}
${excludeGroupIds}
${remoteresources.skip}
${project.build.directory}/maven-shared-archive-resources
${excludeArtifactIds}
${excludeTransitive}
${includeGroupIds}
${session}
${project}
${includeArtifactIds}
appendedResourcesDirectory
java.io.File
false
true
attached
boolean
false
true
excludeArtifactIds
java.lang.String
false
true
excludeGroupIds
java.lang.String
false
true
excludeScope
java.lang.String
false
true
excludeTransitive
boolean
false
true
includeArtifactIds
java.lang.String
false
true
includeGroupIds
java.lang.String
false
true
includeScope
java.lang.String
false
true
localRepository
org.apache.maven.artifact.repository.ArtifactRepository
true
false
mavenSession
org.apache.maven.execution.MavenSession
true
false
The Maven session.
outputDirectory
java.io.File
false
true
project
org.apache.maven.project.MavenProject
true
false
properties
java.util.Map
false
true
remoteArtifactRepositories
java.util.List
true
false
repositories
java.util.List
true
false
resourceBundles
java.util.List
true
true
resources
java.util.List
true
false
skip
boolean
false
true
supplementalModels
java.lang.String[]
false
true
- we need to know what came from the POM, and validate those
- plugin in any default values
- check to see if anything is missing
In the case of something like Modello where it is common to specify the configuration for all the goals outside the execution block we need to account for creating the right configuration element which includes only those configuration elements for a particular goal that that particular goal understands. We need to walk through the parameters of the Mojo in question and only take the configuration options that apply.