This article address: http://blog.csdn.net/kongxx/article/details/6998965
During Maven's actual use, there are times when doing some old projects from Makefile and Ant to Maven, which requires special processing of some steps, such as compiling JNI code, although Maven has a native plug-in to use, However, you need to rewrite the compilation steps of the original project JNI, which in some cases is obviously not appropriate, for example, when the time pressure is larger. In fact, this situation can be done using MAVEN's Antrun plug-in, the advantage of this is that you can reuse the original written makefile, relatively simple is also the fastest. Specific information can refer to http://maven.apache.org/plugins/maven-antrun-plugin/.
The Antrun of Maven is also very simple to embed in code like the following code fragment:
... <build> <plugins> <plugin> <artifactId>maven-antrun-plugin</artifactId> &
lt;executions> <execution> <id>package</id> <phase>package</phase>
<goals> <goal>run</goal> </goals> <configuration> <tasks>
<echo message= "Make ..."/> <exec dir= "src/main/c" executable= "make" failonerror= "true"/> </tasks> </configuration> </execution> <execution> <id>clean</id&
Gt <phase>clean</phase> <goals> <goal>run</goal> </goals> <co nfiguration> <tasks> <echo message= "Make clean ..."/> <exec dir= "src/main/c" exec
Utable= ' make ' failonerror= ' true ' > <arg line= ' clean '/> </exec> </tasks> </configuration> </execution> </executions> </plugin> </plugins> </build> ...
* The code defines two execution nodes that perform the make and make clean defined in the original makefile. Here you can define the tasks node as any ant task that you want to run;
* Under the first execution node, define the phase as package,goal to run, so that the ant task under the first package node is automatically executed when the "MVN execution" is running;
* Under the second execution node, define the phase as clean,goal to run, so that the ant task under the second execution node is automatically executed when the "MVN clean" is running;