【发布时间】:2015-07-15 19:16:29
【问题描述】:
我正在尝试在项目上使用 Ant 执行自动构建。但是该项目使用的是 maven,即 pom.xml 文件而不是 build.xml。那么,我如何在构建项目时调用这些 pom.xml 文件或表示它们。请帮帮我。
【问题讨论】:
-
为什么要使用 ant 而不是 Maven 来构建?
标签: java maven ant build continuous-integration
我正在尝试在项目上使用 Ant 执行自动构建。但是该项目使用的是 maven,即 pom.xml 文件而不是 build.xml。那么,我如何在构建项目时调用这些 pom.xml 文件或表示它们。请帮帮我。
【问题讨论】:
标签: java maven ant build continuous-integration
如果您已经有一个 pom.xml 声明项目的依赖项,您可以通过 ant tasks 在 ant 脚本中使用这些声明。
下载 jar 库后,它就像(都在你的 build.xml 中):
加载任务定义:
<taskdef resource="org/apache/maven/artifact/ant/antlib.xml">
<classpath>
<pathelement location="lib/build/maven-ant-tasks-2.1.3.jar"/>
</classpath>
</taskdef>
使用 <pom> 任务加载 pom:
<pom id="pom_id" file="pom.xml"/>
使用 <dependencies> 任务从 pom 加载文件集:
<dependencies filesetId="deps.compile" pomRefId="pom_id" useScope="compile"/>
<dependencies filesetId="deps.test" pomRefId="pom_id" useScope="test"/>
【讨论】: