Maven Combat Antrun Plugin

Source: Internet
Author: User
Tags echo message

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;



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.