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

maven, maven-antrun-plugin

Solution

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

Problem

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".

Original source