【问题标题】:if doesn't support the nested "equals" element in ant build fileif 不支持 ant 构建文件中嵌套的 "equals" 元素
【发布时间】:2020-09-19 05:45:03
【问题描述】:

下面是我的代码。我们正在使用 Ant 版本 1.9.11 并尝试使用 ant-contrib-1.0b3.jar 和 ant-contrib-1.0b2.jar。

<taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
<taskdef resource="net/sf/antcontrib/antlib.xml"/>

<target name=abc>
<if>
  <equals arg1="${xyz}" arg2="true"/>
  <then>
    <replace file="src/com/xyz.java" token="DEBUG = false;" value="DEBUG = true;" />
  </then>
  <else>
    <echo message="${xyz} is not enabled "/>
  </else>           
</if>   
</target>

我也尝试过使用 ant contrib 的完整路径,如下所示,但仍然遇到相同的错误。

<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath>
  <pathelement location="/opt/apache-ant-1.9.11/lib/ant-contrib-1.0b3.jar"/>
</classpath>

非常感谢帮助我解决此问题。

【问题讨论】:

    标签: ant ant-contrib


    【解决方案1】:

    根据antcontrib site,使用antcontrib.properties 的taskdef 仅适用于Ant 1.5 版,因此您需要使用antlib.xml taskdef。而且您将需要您尝试过的嵌套类路径,因此在您的情况下,您可能需要以下内容:

    <taskdef resource="net/sf/antcontrib/antlib.xml">
      <classpath>
        <pathelement location="/opt/apache-ant-1.9.11/lib/ant-contrib-1.0b3.jar"/>
      </classpath>
    </tsakdef>
    

    【讨论】:

    • 感谢您花时间在此发布您的答案。我已尝试按要求更改蚂蚁,但仍然出现相同的错误。
    • 它适用于我的 if 任务!尝试运行 ant -v 并检查输出是否存在问题。
    猜你喜欢
    • 1970-01-01
    • 2015-10-27
    • 2012-05-13
    • 2016-12-16
    • 1970-01-01
    • 1970-01-01
    • 2015-10-21
    • 1970-01-01
    • 2023-01-14
    相关资源
    最近更新 更多