I have just translated an ant project into maven however since maven does not really deal with deployment I introduce some antrun into the build. However when I try to execute it the plugin skips my tasks. for exemple when I run mvn clean antrun:run I get the following message: No ant target defined – SKIPPED. the same happends to the second phase in which I am trying to override the deployment phase to do an actual deploy rather to upload to a repository.
Please find below an extract of my pom.xml (type:pom):
<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>
<execution>
<id>deployment</id>
<configuration>
<task>
<echo>Deploying website</echo>
</task>
<tasks>
<echo>Copying website artifact to deployment </echo>
<mkdir dir="${deployRoot}/mydir/${env}" />
<unzip
src="${project.basedir}/target/${env}.${project.version}.zip"
dest="${deployRoot}/mydir/${env}" />
<chmod perm="ugo+rx">
<fileset dir="${deployRoot}/mydir/${env}/web-exploded/bin">
<include name="**/*.sh" />
<include name="**/*.bat" />
</fileset>
</chmod>
</tasks>
</configuration>
<phase>deploy</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
In your
pom.xml, you define two types of executions:cleanphasedeployphase. Note, by the way, that for Maven,deploydoes not mean deploy my (web-)application on a server but deploy the artifact on a remote repository. Please read thedeployplugin information for more details.So if you run the command mvn deploy, when the Maven lifecycle reaches the
deployphase, it will run the plugin execution (the second one in yourpom.xml).However, in your case, you are not running the default Maven lifecycle, as your command is mvn antrun:run (I am not considering the
cleangoal here as it does not matter for the problem). This can be translated in Maven to run the antrun plugin, with the goal run. The problem with that is that you do not define any configuration (which contains the Ant tasks) for a direct call to your Ant plugin.So two solutions:
installphase, and then run themvn clean installinstead ofmvn antrun:run. Note that in this case, you will run the whole Maven lifecycle (i.e. compilation, tests, packaging).<configuration>block to be a child of the<plugin>definition.If you choose the second solution, you will have a
pom.xmllike this one: