问题
I'm using Maven AntRun plugin 1.6 and from their example I cannot code the following ant task to be executed.
Example url: http://maven.apache.org/plugins/maven-antrun-plugin/examples/classpaths.html
I just get the following message when I execute mvn antrun:run. No ant target defined - SKIPPED
What am I doing wrong?
Here's my POM:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<configuration>
<target>
<property name="compile_classpath" refid="maven.compile.classpath" />
<property name="runtime_classpath" refid="maven.runtime.classpath" />
<property name="test_classpath" refid="maven.test.classpath" />
<property name="plugin_classpath" refid="maven.plugin.classpath" />
<echo message="compile classpath: ${compile_classpath}" />
<echo message="runtime classpath: ${runtime_classpath}" />
<echo message="test classpath: ${test_classpath}" />
<echo message="plugin classpath: ${plugin_classpath}" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
回答1:
Since you have configured the maven antrun plugin in your pom.xml
, you only need to call the lifecycle goal configured for the plugin. In this case
mvn compile
This will do the needful.
回答2:
try this
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>default-cli</id>
<configuration>
<target>
<property name="compile_classpath" refid="maven.compile.classpath" />
<property name="runtime_classpath" refid="maven.runtime.classpath" />
<property name="test_classpath" refid="maven.test.classpath" />
<property name="plugin_classpath" refid="maven.plugin.classpath" />
<echo message="compile classpath: ${compile_classpath}" />
<echo message="runtime classpath: ${runtime_classpath}" />
<echo message="test classpath: ${test_classpath}" />
<echo message="plugin classpath: ${plugin_classpath}" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
note the id
<id>default-cli</id>
and run the command
mvn antrun:run
reason for doing this way: if you don't actually want to "compile", running "mvn compile" to execute something else could be counter productive.
来源:https://stackoverflow.com/questions/6271930/maven-antrun-not-executing-tasks