Reputation: 2890
I have problem with ordering Maven plugin executions. I would like to execute the plugins in declaration order:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>task-1</id>
<goals>
<goal>run</goal>
</goals>
<phase>initialize</phase>
<configuration>
<target>
</target>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>task-2</id>
<goals>
<goal>exec</goal>
</goals>
<phase>initialize</phase>
</execution>
</executions>
<configuration>
<executable>cmd</executable>
<arguments>
<argument>/c</argument>
<argument>rem</argument>
</arguments>
</configuration>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>task-3</id>
<goals>
<goal>run</goal>
</goals>
<phase>initialize</phase>
<configuration>
<target>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
I expected the execution order: task-1, task-2, task-3
But after executing mvn initialize
, the actual order is task-1, task-3, task-2:
[INFO] --- maven-antrun-plugin:1.3:run (task-1) @ test ---
[INFO] Executing tasks
[INFO] Executed tasks
[INFO]
[INFO] --- maven-antrun-plugin:1.3:run (task-3) @ test ---
[INFO] Executing tasks
[INFO] Executed tasks
[INFO]
[INFO] --- exec-maven-plugin:1.4.0:exec (task-2) @ test ---
What should I change to execute the plugins in the order I want?
Upvotes: 1
Views: 3503
Reputation: 12335
I expect that Maven warned about a duplicate plugin, i.e. maven-antrun-plugin. Maven cannot have duplicate plugins, so the result is that the executionblock of task-3 is merged into the first maven-antrun-plugin. And now Maven will go through all plugins, top-down and look for execution blocks bound to the validate-phase. This explains the result. Is there an option to control the order in this case? No, not within the same phase.
Upvotes: 3