Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Abandoned
-
3.0.5, 3.1.0
-
None
-
None
Description
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, when run with 'mvn validate', '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.
<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>
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.