In Maven 3.0.3 and later, there are two rules
- Plugin executions are ordered according to their phases. See
https://maven.apache.org/ref/current/maven-core/lifecycles.html for
the order of phases.
For example, here mavin-plugin-1 is executed before maven-plugin-2
because the process-resources phase is defined as taking place before
the compile phase.
<plugin>
<artifactId>maven-plugin-2</artifactId>
<version>1.0</version>
<executions>
<execution>
<phase>compile</phase>
...
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-plugin-1</artifactId>
<version>1.0</version>
<executions>
<execution>
<phase>process-resources</phase>
...
</execution>
</executions>
</plugin>
- If multiple executions have the same phase, then the first one to be
executed will be the built-in one (e.g. maven-compiler-plugin) whose id
is default-something, then the other executions will take place in the
order they appear in your pom file.
For example, if you have this somewhere in your pom
<plugin>
<artifactId>maven-plugin-1</artifactId>
<version>1.2.3</version>
<executions>
<execution>
<id>my-compile</id>
<phase>compile</phase>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-plugin-2</artifactId>
<version>4.5.6</version>
<executions>
<execution>
<id>my-compile-2</id>
<phase>compile</phase>
</execution>
</executions>
</plugin>
and this anywhere in your effective pom
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<executions>
<execution>
<id>**default-compile**</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
...
</executions>
</plugin>
then maven-compiler-plugin will execute maven-compiler-plugin followed by maven-plugin-1, and maven-plugin-2.
If you want maven-compiler-plugin:compile goal to execute after maven-plugin-1 then you could do this
<plugin>
<artifactId>maven-plugin-1</artifactId>
<version>1.2.3</version>
<executions>
<execution>
<id>my-compile</id>
<phase>compile</phase>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<executions>
<execution>
<id>something-other-than-**default-compile**</id>
<phase>compile</phase>
</execution>
<execution>
<id>**default-compile**</id>
<phase>none</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>