无法创建任务或输入if

Tin*_*hom 2 apache ant

我收到以下错误

      failed to create task or type target
Run Code Online (Sandbox Code Playgroud)

Linux操作系统

Ant版本是1.7.1

我必须在这个类型的ant库中包含任何jar吗?

下面是我的Build.xml代码的一部分

<target name="wrapFiles">
    <fileset dir="${proc_src_path}" id="src.sql">
        <exclude name="**/.svn/**"/>
    </fileset>  
    <echo message="Initiating Wrap" />
    <echo message="${src.sql}" />
    <pathconvert pathsep="," property="sql.files.present" refid="src.sql"/> 
    <if>
        <equals arg1="${sql.files.present}" arg2="" />
        <then>
            <echo message="No file found. Skipping Wrapping of files." />
        </then>
    <else>
        <echo message="Files found. Proceeding with wrapping of files" />
        <foreach target="wrapFile" param="toWrap">
            <path>  
                <fileset dir="${proc_src_path}" casesensitive="yes">
                    <exclude name="**/*.txt"/>
                    <exclude name="**/*.TXT"/>
                    <exclude name="**/pkg_*_spec.SQL"/>
                    <exclude name="**/pkg_*_spec.sql"/>
                    <exclude name="**/PKG_*_SPEC.sql"/>
                    <exclude name="**/PKG_*_SPEC.SQL"/>
                    <exclude name="**/*.svn/**"/>
                </fileset>          
            </path>  
        </foreach>
    </else>
    </if>

</target>
Run Code Online (Sandbox Code Playgroud)

Reb*_*bse 6

Ant需要路径上的antcontrib,然后使用:

<project xmlns:ac="antlib:net.sf.antcontrib">

<ac:if>
...
</ac:if>

</project>
Run Code Online (Sandbox Code Playgroud)

要么 :

<project>

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

<if>
...
</if>

</project>
Run Code Online (Sandbox Code Playgroud)

使用多个ant插件时,首选通过命名空间进行安装.
为了保持你的ant核心安装干净,不要将antcontrib.jar放在%ANT_HOME%\ lib中,而是为ant addon jars创建一个文件夹,并使用类似的东西启动你的ant脚本:

Windows

@ echo off

set ANT_ARGS=-lib C:\path\to\ant\extralibs
set ANT_HOME=C:\path\to\ant
set ANT_OPTS=-Xmx1024m
set JAVA_HOME=%ProgramFiles(x86)%\JavaSoft\JDK\1.7.0_60
set PATH=%JAVA_HOME%\bin;%ANT_HOME%\bin;%PATH%

:: DEFAULT
call ant -f %1

:: DEBUG
:call ant -debug -Dfoo=bar -f %1

pause
Run Code Online (Sandbox Code Playgroud)

Linux/Unix =>不要忘记ANT_ARGS行上的引号!

  ...
  ANT_ARGS="-lib /usr/local/ant_xtralibs:/usr/local/ant_testlibs"
  export ANT_ARGS
  ...
Run Code Online (Sandbox Code Playgroud)