Performing specific Ant tasks in pom.xml
I've been trying to find a good way to specify some ant tasks(defined in build.xml) in pom.xml of a Maven project. For example, in my build.xml, I have the following line of code;
<target name="clean">
<delete dir="dist"/>
<delete dir="build"/>
</target>
How can I perform this action in my pom.xml?
Use maven-antrun-plugin.
You can put in the target ANT commands. Here the example of the maven-antrun-plugin on phase install that execute your commands:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>file-exists</id>
<phase>install</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<delete dir="dist"/>
<delete dir="build"/>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
以下是做这些事情的maven方式:
<build>
[...]
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.5</version>
<configuration>
<filesets>
<fileset>
<directory>${project.basedir}/dist</directory>
<includes>
<include>**/*</include>
</includes>
</fileset>
<fileset>
<directory>${project.basedir}/build</directory>
<includes>
<include>**/*</include>
</includes>
</fileset>
</filesets>
</configuration>
</plugin>
[...]
</build>
链接地址: http://www.djcxy.com/p/44324.html
上一篇: Maven(m2e)不执行ant任务
下一篇: 在pom.xml中执行特定的Ant任务