假设您已经从 maven 创建并维护了您的项目很长时间,但是现在您有了将其移至 Ant 构建环境的说明。 好吧,这看起来并不容易,但是确实很多。
仅用于此目的的 maven ant 插件即可使用。
$ mvn ant:ant
让我们看一个详细的示例,以使用 maven ant 插件从 maven pom 文件生成 ant 构建文件。
1. 创建示例 Maven 项目
$ mvn archetype:generate-DgroupId=com.howtodoinjava-DartifactId=antBuildScriptDemo-DarchetypeArtifactId=maven-archetype-quickstart-DinteractiveMode=false
2. 从pom.xml生成 ant 脚本
$ cd antBuildScriptDemo$ mvn ant:ant
3. 从pom.xml生成build.xml的演示
上面的命令将在项目根文件夹中生成 3 个文件。
build.xmlmaven-build.properiesmaven-build.xml
要运行上面生成的 ant 文件,请在系统中安装 ant 并执行如下所示的build.xml文件:
ant build.xml
学习愉快!
参考: http://maven.apache.org/plugins/maven-ant-plugin/index.html
