[英]copy doesn't support the nested “if” element in Ant-contrib Nested Loop
[英]if doesn't support the nested "equals" element in ant build file
下面是我的代碼。 我們正在使用 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>
非常感謝幫助我解決這個問題。
根據antcontrib 站點,使用 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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.