3

I am getting the following error

      failed to create task or type target

Linux OS

Ant Version is 1.7.1

Is there any jar that i must include in the ant library for this type?

Below is my part of my Build.xml code

<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>
TinsThom
  • 33
  • 1
  • 1
  • 4
  • 2
    Is it "failed to create task or type target" or "failed to create task or type if"? Please update your post to reflect on the correct problem. – M A Jul 07 '14 at 10:42
  • 1
    When I ran the code in my local system(Windows OS) using bat file, the error was 'failed to create task or type if'. When I ran the code in a common environment(Linux OS) using the sh file, the error was 'failed to create task or type target' – TinsThom Jul 07 '14 at 10:53
  • Please check http://stackoverflow.com/questions/6336792/ant-using-conditional-tags-if – M A Jul 07 '14 at 10:59
  • See: http://stackoverflow.com/questions/12891893/how-to-include-ant-contrib-jar-dynamically-in-ant/12900768#12900768 – Mark O'Connor Jul 07 '14 at 21:38

1 Answers1

8

Ant needs antcontrib on path, then use :

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

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

</project>

or :

<project>

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

<if>
...
</if>

</project>

When using several ant addons, the installation via namespaces is to be preferred.
To keep your ant core installation clean, don't put antcontrib.jar in %ANT_HOME%\lib, create a folder for ant addon jars instead and use something like that to start your ant scripts :

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

Linux/Unix => don't forget the quotationmarks on the ANT_ARGS line !

  ...
  ANT_ARGS="-lib /usr/local/ant_xtralibs:/usr/local/ant_testlibs"
  export ANT_ARGS
  ...
Rebse
  • 10,307
  • 2
  • 38
  • 66