原文链接 译者:carvendy
Maven使用Ant指南
这个例子中说明咱们绑定一个ant脚本到生命周期。你可以加入脚本到每一个生命周期,复制 execution/ section可以指定一个新的周期。
<project> <modelVersion>4.0.0</modelVersion> <artifactId>my-test-app</artifactId> <groupId>my-test-group</groupId> <version>1.0-SNAPSHOT</version> <build> <plugins> <plugin> <artifactId>maven-antrun-plugin</artifactId> <version>1.7</version> <executions> <execution> <phase>generate-sources</phase> <configuration> <tasks> <!-- Place any ant task here. You can add anything you can add between <target> and </target> in a build.xml. --> </tasks> </configuration> <goals> <goal>run</goal> </goals> </execution> </executions> </plugin> </plugins> </build></project>
一个具体的例子像下面这样:
<project> <modelVersion>4.0.0</modelVersion> <artifactId>my-test-app</artifactId> <groupId>my-test-group</groupId> <version>1.0-SNAPSHOT</version> <build> <plugins> <plugin> <artifactId>maven-antrun-plugin</artifactId> <version>1.7</version> <executions> <execution> <phase>generate-sources</phase> <configuration> <tasks> <exec dir="" executable="/src/main/sh/do-something.sh" failonerror="true"> <arg line="arg1 arg2 arg3 arg4" /> </exec> </tasks> </configuration> <goals> <goal>run</goal> </goals> </execution> </executions> </plugin> </plugins> </build></project>