【问题标题】:Automated build with Ant [duplicate]使用 Ant 自动构建 [重复]
【发布时间】:2015-07-15 19:16:29
【问题描述】:

我正在尝试在项目上使用 Ant 执行自动构建。但是该项目使用的是 maven,即 pom.xml 文件而不是 build.xml。那么,我如何在构建项目时调用这些 pom.xml 文件或表示它们。请帮帮我。

【问题讨论】:

  • 为什么要使用 ant 而不是 Maven 来构建?

标签: java maven ant build continuous-integration


【解决方案1】:

如果您已经有一个 pom.xml 声明项目的依赖项,您可以通过 ant tasks 在 ant 脚本中使用这些声明。

下载 jar 库后,它就像(都在你的 build.xml 中):

  1. 加载任务定义:

    <taskdef resource="org/apache/maven/artifact/ant/antlib.xml"> <classpath> <pathelement location="lib/build/maven-ant-tasks-2.1.3.jar"/> </classpath> </taskdef>

  2. 使用 &lt;pom&gt; 任务加载 pom:

    &lt;pom id="pom_id" file="pom.xml"/&gt;

  3. 使用 &lt;dependencies&gt; 任务从 pom 加载文件集:

    <dependencies filesetId="deps.compile" pomRefId="pom_id" useScope="compile"/> <dependencies filesetId="deps.test" pomRefId="pom_id" useScope="test"/>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-21
    • 1970-01-01
    相关资源
    最近更新 更多