How to call maven-antrun-plugin target without attach execution to a maven phase ?

Antoine picture Antoine · May 11, 2012 · Viewed 7.9k times · Source

I use maven-antrun-plugin for init config files for my project. But i need to init config files just once, when i first start to init my dev environment, not each time i launch jetty:run.

If I attach phase to process-resouces for example, each time I launch jetty, my config files are reseted.

So i configured antrun like this :

<plugin>
    <artifactId>maven-antrun-plugin</artifactId>
    <executions>
        <execution>
        <goals>
            <goal>run</goal>
        </goals>
        <configuration>
            <target name="init_config_files">
                <!-- init files -->
            </target>
        </configuration>
        </execution>
    </executions>
</plugin>

If I launch mvn antrun:run, it just return me this error : "[INFO] No ant target defined - SKIPPED". And it is the same thing, if I specify target : "mvn antrun:run -Dtarget=init_config_files".

Answer

Titi Wangsa Bin Damhore picture Titi Wangsa Bin Damhore · Jun 13, 2012

Try this:

        <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" />
                            <echo message="compile classpath: ${compile_classpath}" />
                        </target>
                    </configuration>
                    <goals>
                        <goal>run</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

and run this:

 mvn antrun:run