blob: d0390360162a11a32bc81ef3f7bc941b3cdeea7c [file] [log] [blame]
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.
<configuration>
<lifecycles>
<lifecycle>
<id>default</id>
<phases>
<process-resources>org.apache.maven.plugins:maven-resources-plugin:resources</process-resources>
<compile>org.apache.maven.plugins:maven-compiler-plugin:compile</compile>
<process-test-resources>org.apache.maven.plugins:maven-resources-plugin:testResources</process-test-resources>
<test-compile>org.apache.maven.plugins:maven-compiler-plugin:testCompile</test-compile>
<test>org.apache.maven.plugins:maven-surefire-plugin:test</test>
<package>org.apache.maven.plugins:maven-jar-plugin:jar</package>
<install>org.apache.maven.plugins:maven-install-plugin:install</install>
<deploy>org.apache.maven.plugins:maven-deploy-plugin:deploy</deploy>
</phases>
</lifecycle>
</lifecycles>
</configuration>
We need to turn this list of phases into a set of plugin objects that have an xml representation like the following:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>process</goal>
</goals>
</execution>
</executions>
</plugin>
.
.
.
</plugins>
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:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>1.0</version</version>
<executions>
<execution>
<goals>
<goal>process</goal>
</goals>
</execution>
</executions>
</plugin>
.
.
.
</plugins>
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 <configuration/> element and <parameters/> 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 configure 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
<configuration>
<attached implementation="boolean" default-value="true"/>
<localRepository implementation="org.apache.maven.artifact.repository.ArtifactRepository">${localRepository}</localRepository>
<resources implementation="java.util.List">${project.resources}</resources>
<repositories implementation="java.util.List">${project.repositories}</repositories>
<remoteArtifactRepositories implementation="java.util.List">${project.remoteArtifactRepositories}</remoteArtifactRepositories>
<appendedResourcesDirectory implementation="java.io.File">${basedir}/src/main/appended-resources</appendedResourcesDirectory>
<excludeScope implementation="java.lang.String" default-value="">${excludeScope}</excludeScope>
<includeScope implementation="java.lang.String" default-value="runtime">${includeScope}</includeScope>
<excludeGroupIds implementation="java.lang.String" default-value="">${excludeGroupIds}</excludeGroupIds>
<skip implementation="boolean" default-value="false">${remoteresources.skip}</skip>
<outputDirectory implementation="java.io.File">${project.build.directory}/maven-shared-archive-resources</outputDirectory>
<excludeArtifactIds implementation="java.lang.String" default-value="">${excludeArtifactIds}</excludeArtifactIds>
<excludeTransitive implementation="boolean" default-value="false">${excludeTransitive}</excludeTransitive>
<includeGroupIds implementation="java.lang.String" default-value="">${includeGroupIds}</includeGroupIds>
<mavenSession implementation="org.apache.maven.execution.MavenSession">${session}</mavenSession>
<project implementation="org.apache.maven.project.MavenProject">${project}</project>
<includeArtifactIds implementation="java.lang.String" default-value="">${includeArtifactIds}</includeArtifactIds>
</configuration>
<parameters>
<parameter>
<name>appendedResourcesDirectory</name>
<type>java.io.File</type>
<required>false</required>
<editable>true</editable>
</parameter>
<parameter>
<name>attached</name>
<type>boolean</type>
<required>false</required>
<editable>true</editable>
</parameter>
<parameter>
<name>excludeArtifactIds</name>
<type>java.lang.String</type>
<required>false</required>
<editable>true</editable>
</parameter>
<parameter>
<name>excludeGroupIds</name>
<type>java.lang.String</type>
<required>false</required>
<editable>true</editable>
</parameter>
<parameter>
<name>excludeScope</name>
<type>java.lang.String</type>
<required>false</required>
<editable>true</editable>
</parameter>
<parameter>
<name>excludeTransitive</name>
<type>boolean</type>
<required>false</required>
<editable>true</editable>
</parameter>
<parameter>
<name>includeArtifactIds</name>
<type>java.lang.String</type>
<required>false</required>
<editable>true</editable>
</parameter>
<parameter>
<name>includeGroupIds</name>
<type>java.lang.String</type>
<required>false</required>
<editable>true</editable>
</parameter>
<parameter>
<name>includeScope</name>
<type>java.lang.String</type>
<required>false</required>
<editable>true</editable>
</parameter>
<parameter>
<name>localRepository</name>
<type>org.apache.maven.artifact.repository.ArtifactRepository</type>
<required>true</required>
<editable>false</editable>
</parameter>
<parameter>
<name>mavenSession</name>
<type>org.apache.maven.execution.MavenSession</type>
<required>true</required>
<editable>false</editable>
<description>The Maven session.</description>
</parameter>
<parameter>
<name>outputDirectory</name>
<type>java.io.File</type>
<required>false</required>
<editable>true</editable>
</parameter>
<parameter>
<name>project</name>
<type>org.apache.maven.project.MavenProject</type>
<required>true</required>
<editable>false</editable>
</parameter>
<parameter>
<name>properties</name>
<type>java.util.Map</type>
<required>false</required>
<editable>true</editable>
</parameter>
<parameter>
<name>remoteArtifactRepositories</name>
<type>java.util.List</type>
<required>true</required>
<editable>false</editable>
</parameter>
<parameter>
<name>repositories</name>
<type>java.util.List</type>
<required>true</required>
<editable>false</editable>
</parameter>
<parameter>
<name>resourceBundles</name>
<type>java.util.List</type>
<required>true</required>
<editable>true</editable>
</parameter>
<parameter>
<name>resources</name>
<type>java.util.List</type>
<required>true</required>
<editable>false</editable>
</parameter>
<parameter>
<name>skip</name>
<type>boolean</type>
<required>false</required>
<editable>true</editable>
</parameter>
<parameter>
<name>supplementalModels</name>
<type>java.lang.String[]</type>
<required>false</required>
<editable>true</editable>
</parameter>
</parameters>
- 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.