maven诚可贵,ant价更高,若为构建顾,两者皆可顾。诚然,依赖管理和构建方面,maven是强项,但是在文件操作方面,老牌的ant显然更强大。那么又没有什么方法能把他们的各自的强项结合起来呢?
如果我们希望maven在构建完成后使用进行其他文件操作,可以使用maven-antrun-plugin
插件
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<configuration>
<target>
<!-- 在这里添加ant操作 -->
...
</target>
</configuration>
</plugin>
在target中可以像在ant的build.xml中那样添加任何ant操作,例如移动、复制文件,创建目录,甚至重启tomcat等。