【问题标题】:Ant inheriting Maven propertiesAnt 继承 Maven 属性
【发布时间】:2023-04-05 12:07:01
【问题描述】:

我正在考虑将 Ant/Ivy 项目转换为 Ant/Maven-Ant-Tasks。我不想单独使用 Maven,因为我需要对构建过程进行更多控制。

有没有办法让Ant build.xml文件继承pom.xml文件中设置的属性?

我一直在创建一个通用的 build.xml 文件,它可以在多个项目中使用并加载一个特定于项目的 project.properties 文件,但是如果我可以将所有这些属性都放在 pom.xml 文件中会更好.

谢谢。

【问题讨论】:

    标签: maven-2 ant


    【解决方案1】:

    我使用 XMLProperty ant 任务来解析和复制这些属性

    http://ant.apache.org/manual/Tasks/xmlproperty.html

    <xmlproperty file="<your pom location>" keepRoot="false"/>
    <property name="test"   value="${properties.test}"/>
    

    另一种选择,如果您使用 maven Antrun 插件运行构建,属性将可在构建文件中使用

    http://maven.apache.org/plugins/maven-antrun-plugin/usage.html

    【讨论】:

    • 感谢 mavn-antrun-plugin 提示。我使用它,但不知道我可以访问属性。
    猜你喜欢
    • 2012-12-22
    • 2011-04-21
    • 2013-12-02
    • 1970-01-01
    • 2011-04-04
    • 1970-01-01
    • 2014-02-03
    • 1970-01-01
    • 2012-05-08
    相关资源
    最近更新 更多