I am new to maven. I would like to change the order of maven plug-in execution.
In my pom.xml, I have maven-assembly-plugin and maven-ant-plugin .I have used maven-assembly-plugin for creating zip file and maven-ant-plugin for copying the zip file from target to some other directory. When I run pom.xml, maven-ant- plugin got triggered and looking for zip file finally I got the error saying zip file not found. Please suggest me the way how to run maven-assembly-plugin first after that maven-ant-plugin needs to run so that it will copy zip file to the corresponding directory.
In Maven 3.0.3 and later, there are two rules
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.
For example, if you have this somewhere in your pom
and this anywhere in your effective pom
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
Plugins in the same phase are executed in the declared order.
In the case of pom hierachy, you have to re-declare the plugins from the parent pom (just its groupId and its artifactId) into the child pom to specify the execution order :
Parent pom.xml
Child pom.xml
Then the execution is :
Since you say you are very new to Maven....Maven builds are executions of an ordered series of phases. These phases are determined by the lifecycle that is appropriate to your project based on its packaging.
Therefore, you control when a plugin's goal is executed by binding it to a particular phase.
Hope that helps.
EDIT: Also, since Maven 3.0.3, for two plugins bound to the same phase, the order of execution is the same as the order in which you define them. For example:
In the above instance, the execution order would be: