David Eckel created MNG-5539:
--------------------------------
Summary: Profile plugin execution order is not preserved when
merging into default PluginContainer
Key: MNG-5539
URL: https://jira.codehaus.org/browse/MNG-5539
Project: Maven 2 & 3
Issue Type: Bug
Components: Plugins and Lifecycle, POM, Profiles
Affects Versions: 3.1.0, 3.0.5
Reporter: David Eckel
Priority: Minor
The order of execution of plugins within a profile unexpectedly depends upon
the order of plugin definitions outside of the profile if the profile
references those same plugins, even if they do not specify executions in the
same phase. In the following example pom snippet, 'plugin-B-in-profile' will
execute first, then 'plugin-A-in-profile', when the opposite execution - the
order in which they were defined - was desired.
{code:xml}
<build>
<plugins>
<!-- if you swap the order of these two plugins or remove one,
the order of the profile plugin execution will change -->
<plugin>
<artifactId>maven-jar-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>plugin-A-in-profile</id>
<phase>validate</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<executions>
<execution>
<id>plugin-B-in-profile</id>
<phase>validate</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Removing this plugin declaration will
cause above plugins to run in a different order -->
<plugin>
<artifactId>maven-jar-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>
{code}
See
{{org.apache.maven.model.profile.DefaultProfileInjector$ProfileModelMerger.mergePluginContainer_Plugins()}}.
It's unclear to me if this algorithm is intentional to aggregate all plugin
definitions in the same way that you cannot declare the same plugin more than
once in a given PluginContainer, or if profiles should always have their
execution order respected, regardless of plugin definitions outside of the
profile.
This may be a similar or the same issue as MNG-5478, but it's unclear due to
lack of information.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira