Win a copy of Terraform in Action this week in the Cloud forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Problem: failed to create task or type for Cause: The name is undefined.

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there

I was trying to iterate a list using for tag in my build.xml. But getting this error:



My build .xml looks like this:


Can anybody tell where I am doing wrong

FYI: I am using eclipse 3.5 which has ANT3.7
 
author
Posts: 3281
8
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is the for task a standard task in ANT?
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The "for" task is in ant-contrib. Have you installed it correctly? Have you provided a taskdef for it that you're not showing here?

http://ant-contrib.sourceforge.net/
 
zabin shariff
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

It seems I have not provided a typedef for "for" . I corrected myself and changed my code to this:


I got this error:


So I checked the plugins library in eclipse folder and found that there is no ant-lib there. So I downloaded one and copied it to the lib folder of the ant plugin. But still I am getting the same error. Do I need to set the path somewhere. I am using Eclipse Galileo 3.5 which has ANT as plugin so i haven't downloaded ANT and configured it in my system manually.
Any suggestions
 
zabin shariff
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there
I got the solution
I imported the jar(ant-contrib-1.0b3 which I have downloaded and kept in eclipse/plugins/org.apache.ant_1.7.1.v20090120-1145/lib) in Eclipse, by Windows--?Preferences-->Ant-->Runtime--->Add External Jars in Ant Home Entries.
Now my build.xml is working fine:
Here is my snippet:

 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Glad to hear you got it working!
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One more addition - sometimes ant is thick about finding its lib directory, so it doesn't look like you added the ant-contrib-jar even when you did.
One way to check that is to add a -lib <hard path to your ant lib directory> to the end of your ant command line & see if this problem goes away.
If so, ant is looking in the wrong lib directory on your system.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hello All,
I am also getting same issue

Generating code coverage with Ant and Jacoco.
In my project we are using Ant, Sonar and Gitlab CI/CD pipelines. I am new to Ant buidl.xml
Can any one help me to fix the issue
build.xml file contains
<?xml version="1.0"?>

<project name="Agile" xmlns:jacoco="antlib:org.jacoco.ant" default="test" basedir="." xmlns:if="ant:if" xmlns:unless="ant:unless">

  <property  file="Buildinputs.properties"/>

  <property name="srcdir" value="${basedir}" />

  <property name="lib.dir" value="${basedir}/lib" />

  <property name="war.dir" value="${DestinationPath}/Wars" />

  <property name="jar.dir" value="${DestinationPath}/Jars" />

  <property name="jacoco.jar" location="../monet-main/lib/dev/sonar/jacocoant.jar" />

  

  <!--taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">

      <classpath>

        <pathelement location="${basedir}/commonlib/antcontrib.jar"/>

        <pathelement location="${jacocoant.jar}"/>

      </classpath>

  </taskdef>-->

   

  <path id="compile-test.classpath">

     <pathelement location="./lib/junit-4.12.jar" />

     <pathelement location="./lib/hamcrest-core-1.3.jar" />

     <pathelement location="./lib/org.jacoco.ant-0.7.2.201409121644.jar"/>

     <pathelement location="./lib/ant-contrib-1.0b3.jar" />

     <pathelement location="target/classes"/>

  </path>

  

  <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">

        <classpath refid="compile-test.classpath" />

        <classpath path="lib/test/org.jacoco.ant.jar"/>

  </taskdef>

  <taskdef name="jacoco-coverage" classname="org.jacoco.ant.CoverageTask" />

  <taskdef name="jacoco-report" classname="org.jacoco.ant.ReportTask" />

  <taskdef name="findbugs" classname="edu.umd.cs.findings.anttask.FindBugsTask" />

  

  <property environment="env" />

  <tstamp prefix="build-info">

    <format property="current-date" pattern="d-MMMM-yyyy" locale="en" />

    <format property="current-time" pattern="hh:mm:ss a z" locale="en" />

  </tstamp>

  

  <path id="compileJar.path">

   <fileset dir="${basedir}/lib">

      <include name="*.jar"/>

      <include name="*.zip"/>

    </fileset> 

    <fileset dir="${basedir}/commonlib">

      <include name="*.jar"/>

      <include name="*.zip"/>

    </fileset>

  </path>

  <target name="jar" depends="compile">

    <antcall target="compile">

      <param name="Service_Name" value="${Service_Name}"/>

      <param name="Artifact_Type" value="jar"/>

    </antcall>

    

    <jar destfile="${jar.dir}/${Jar_Name}" >

      <fileset dir="src"/>      

      <manifest>

        <attribute name="Built-Copyright" value="${build-copyright-info}"/>

        <attribute name="Built-By" value="${user.name}" />

        <attribute name="Built-On" value="${build-info.current-date}" />

        <attribute name="Built-Time" value="${build-info.current-time}" />

        <attribute name="Build-Number" value="${env.BUILD_BUILDNUMBER}" />

      </manifest>

    </jar>

    <!--<zip destfile="${DestinationPath}/${Service_Name}.zip" basedir="${jar.dir}" update="true" />-->

    <echo message="**************JAR created successfully : ${Service_Name}**************" />

  </target>

  

  <target name="clean">

    <delete dir="target"/>

    <delete dir="${build.dir}" />

  </target>

  

    <!-- Create target  folder>-->

  <target name="prepare" depends="clean">

    <mkdir dir="target/classes"/>

    <mkdir dir="target/test-classes"/>

    <copy includeemptydirs="false" todir="target/classes">

           <fileset dir="src/main/java">

              <exclude name="**/*.java"/>

           </fileset>

    </copy>

    

    <copy includeemptydirs="false" todir="target/test-classes">

       <fileset dir="src/test/java">

                <exclude name="**/*.java"/>

            </fileset>

    </copy>     

  </target>

  <target name="compile" depends="prepare">

     <javac srcdir="." destdir="target/test-classes" debug="true"  includeantruntime="false"  classpathref="compileJar.path" />

               

  </target>

  <target name="test" depends="jar">

      <jacoco:coverage destfile="target/"  xmlns:jacoco="antlib:org.jacoco.ant" exclclassloader="sun.reflect.DelegatingClassLoader:javassist.Loader" >

      <junit haltonfailure="false" printsummary="true" fork="on" forkmode="once">

        <formatter type="brief" usefile="false"/>

        <test name="com.valdimessage.fix44.AccountSetupStrategyTest" filtertrace="true" />

        <batchtest>

             <fileset dir="target/test-classes">

                  <include name="**/*Test*" />

             </fileset>

          </batchtest>

        <classpath>

          <pathelement location="target/test-classes"/>

           <path refid="compile-test.classpath" />

        </classpath>

      </junit>

    </jacoco:coverage>

    

    <echo message="Generating Jacoco reports..." />

     <jacoco:report xmlns:jacoco="antlib:org.jacoco.ant">

      <executiondata>

      <file file="target/jacoco.exec"/>

      </executiondata>

  

      <structure name="jacoco-report">

      <classfiles>

        <fileset dir="target/classes"/>

      </classfiles>

      <sourcefiles encoding="UTF-8">

        <fileset dir="src/main/java"/>

      </sourcefiles>

      </structure>

      <html destdir="target/coverage-report"/>

      <xml destfile="target/coverage-report/report.xml"/>

    </jacoco:report>    

  </target>
</project>
------------------------------
Error Details.
Buildfile: /builds/[MASKED]/Build.xml

[2014](https://gitlab.dell.com/Subhash_Mannem/createandsaveaseventspx/-/jobs/48975411#L2014) [taskdef] Could not load definitions from resource org/jacoco/ant/antlib.xml. It could not be found.

[2015](https://gitlab.dell.com/Subhash_Mannem/createandsaveaseventspx/-/jobs/48975411#L2015)BUILD FAILED

[2016](https://gitlab.dell.com/Subhash_Mannem/createandsaveaseventspx/-/jobs/48975411#L2016)/builds/[MASKED]/Build.xml:28: taskdef class org.jacoco.ant.CoverageTask cannot be found

[2017](https://gitlab.dell.com/Subhash_Mannem/createandsaveaseventspx/-/jobs/48975411#L2017) using the classloader AntClassLoader[]

[2018](https://gitlab.dell.com/Subhash_Mannem/createandsaveaseventspx/-/jobs/48975411#L2018)Total time: 0 seconds

[2020](https://gitlab.dell.com/Subhash_Mannem/createandsaveaseventspx/-/jobs/48975411#L2020)Uploading artifacts for failed job00:00

[2021](https://gitlab.dell.com/Subhash_Mannem/createandsaveaseventspx/-/jobs/48975411#L2021)Uploading artifacts...

[2022](https://gitlab.dell.com/Subhash_Mannem/createandsaveaseventspx/-/jobs/48975411#L2022)WARNING: target/*: no matching files

[2023](https://gitlab.dell.com/Subhash_Mannem/createandsaveaseventspx/-/jobs/48975411#L2023)ERROR: No files to upload

[2025](https://gitlab.dell.com/Subhash_Mannem/createandsaveaseventspx/-/jobs/48975411#L2025)Cleaning up file based variables00:00

[2027](https://gitlab.dell.com/Subhash_Mannem/createandsaveaseventspx/-/jobs/48975411#L2027)ERROR: Job failed: command terminated with exit code 1





 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic