【发布时间】:2014-07-11 08:04:49
【问题描述】:
我无法执行if 任务。
我的代码是:
<?xml version="1.0" ?>
<project default="main">
<property name="buildsequence.property.file.fullpath" value="D:\testant\AntExample" />
<target name="main" depends="compile, compress" description="Main target">
<echo>
Building the .jar file.
</echo>
</target>
<target name="compile" description="Compilation target">
<javac srcdir="src/org" destdir="src/org" fork="yes" executable="C:\Program Files\Java\jdk1.7.0_60\bin\javac"/>
</target>
<target name="compress" description="Compression target">
<jar jarfile="Project.jar" basedir="src/org" includes="*.class" />
<if>
<available file="${buildsequence.property.file.fullpath}" />
<then>
<echo message="File exist"/>
</then>
<else>
<echo message="File do not exist" />
</else>
</if>
</target>
</project>
错误:
Buildfile: D:\projects\Self\AntExample\build.xml
compile:
[javac] Compiling 1 source file to D:\projects\Self\AntExample\src\org
compress:
BUILD FAILED
D:\projects\Self\AntExample\build.xml:19: 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.
注意:文件存在于D:\testant\AntExample。
【问题讨论】:
-
使用 if 任务不是蚂蚁的方式。蚂蚁的方式是使目标验证和其他目标取决于此目标,并且仅在“如果”或“除非”属性设置为 true 时触发它们。见ant.apache.org/manual/targets.html
标签: ant build.xml ant-contrib