Jam*_*sev 10 tags ant if-statement
我想做这样的事情
<target name="clean" description="clean">
<if>
<available file="${build}" type="dir" />
<then>
<delete dir="${build}" />
</then>
</if>
</target>
Run Code Online (Sandbox Code Playgroud)
根据stackoverflow.com上的建议,我下载了ant-contrib-1.0b3.jar并将其放入我的路径中
另外,在Ant Build配置下,在classpath中,我有
运行我的ANT脚本时,我仍然可以
BUILD FAILED
C:\Repositories\blah\build.xml:60: Problem: failed to create task or type if
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.
Run Code Online (Sandbox Code Playgroud)
我错过了什么?请指教
或者,一旦在ANT脚本中包含以下行
<taskdef resource="net/sf/antcontrib/antlib.xml" />
Run Code Online (Sandbox Code Playgroud)
只要ant-contribs
在你的道路上,就不需要别的了
此解决方案更清晰,因为可以访问所有标记,而不仅仅是手动指定的标记
小智 5
以这种方式解决了同样的问题.我在buid XML文件的开头添加了以下行:
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="your/path/to/ant-contrib-${version}.jar" />
</classpath>
</taskdef>
Run Code Online (Sandbox Code Playgroud)