Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven Antrun Not Executing Tasks

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>
like image 517
Joe Intrakamhang Avatar asked Jun 07 '11 21:06

Joe Intrakamhang


People also ask

What does Maven AntRun plugin do?

This plugin provides the ability to run Ant tasks from within Maven. You can even embed your Ant scripts in the POM! It is not the intention of this plugin to provide a means of polluting the POM, so it's encouraged to move all your Ant tasks to a build.

What is Maven AntRun?

Description: Maven AntRun Mojo. This plugin provides the capability of calling Ant tasks from a POM by running the nested Ant tasks inside the <target/> parameter. It is encouraged to move the actual tasks to a separate build. xml file and call that file with an <ant/> task.


2 Answers

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.

like image 137
Titi Wangsa Bin Damhore Avatar answered Sep 19 '22 05:09

Titi Wangsa Bin Damhore


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.

like image 40
Raghuram Avatar answered Sep 20 '22 05:09

Raghuram