In pom.xml you define two types of execution:
- One is associated with the
clean phase. - One is associated with the
deploy phase. Please note that, by the way, for Maven << 22> does not mean deploying my (web application) to the server, but deploying the artifact to a remote repository. Read more about deploy plugin information .
So, if you run the mvn deploy command when the Maven life cycle reaches the deploy phase, it will start the plugin execution (the second one in your pom.xml ).
However, in your case, you are not executing the default Maven life cycle, since your mvn antrun: run command (I do not consider the clean target here, as this does not matter for the problem). This can be translated into Maven to run the antrun plugin with the launch of the target. The problem is that you are not defining any configuration (containing Ant tasks) to directly call your Ant plugin.
So, two solutions:
- Bind the second run to the
install phase, and then run mvn clean install instead of mvn antrun:run . Please note that in this case you will run the entire Maven life cycle (i.e. Compilation, tests, packaging). - Create the configuration of this plugin not related to any execution. In the XML view, just add (or move) the second
<configuration> block as a child of the <plugin> definition.
If you choose the second solution, you will have pom.xml , like this one:
<plugin> <artifactId>maven-antrun-plugin</artifactId> <version>1.6</version> <executions> <execution> <id>clean</id> <configuration> <task> <echo>Cleaning deployed website</echo> </task> <tasks> <delete dir="${deployRoot}/mydir/${env}"/> </tasks> </configuration> <phase>clean</phase> <goals> <goal>run</goal> </goals> </execution> </executions> <configuration> <tasks> <echo>Copying website artifact to deployment </echo> ... </tasks> </configuration> </plugin>
romaintaz
source share