试图使这个目标有条件
Trying to make this target conditional
这就是我想要做的:
<target name="example">
<if>
<equals arg1="${var}" arg2="true" />
<then>
<exec executable="/bin/bash">
<arg value="script.sh" />
</exec>
</then>
</if>
</target>
当我使用 ant 示例执行目标时,出现此错误:
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.
我真的需要帮助。非常感谢
那是因为,if
是来自 ant-contrib
库的自定义任务。
确保 ant-contrib 库在您的 class 路径中。二进制文件可以从 here 下载。将 ant-contrib jar 文件提取到某个位置。并在下面指定相同的 taskdef.
然后在build.xml的开头添加taskdef。请参阅 documentation 了解更多详情。
例如:
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath>
<pathelement location="/absolute/path/to/ant-contrib-1.0b3.jar" />
</classpath>
</taskdef>
这就是我想要做的:
<target name="example">
<if>
<equals arg1="${var}" arg2="true" />
<then>
<exec executable="/bin/bash">
<arg value="script.sh" />
</exec>
</then>
</if>
</target>
当我使用 ant 示例执行目标时,出现此错误:
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.
我真的需要帮助。非常感谢
那是因为,if
是来自 ant-contrib
库的自定义任务。
确保 ant-contrib 库在您的 class 路径中。二进制文件可以从 here 下载。将 ant-contrib jar 文件提取到某个位置。并在下面指定相同的 taskdef.
然后在build.xml的开头添加taskdef。请参阅 documentation 了解更多详情。
例如:
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath>
<pathelement location="/absolute/path/to/ant-contrib-1.0b3.jar" />
</classpath>
</taskdef>