Question

I have an Android build script. It tries to use Gant tasks instead of Ant targets for custom work done on project. The interesting build script's part looks the following way:

<taskdef name="gant" classname="org.codehaus.gant.ant.Gant">
    <classpath>
        <pathelement location="${gant.dir}/gant-1.9.7_groovy-1.8.4.jar" />
    </classpath>
</taskdef>

<target name="-pre-build">
    <gant target="targetA"/>
    <gant target="targetB"/>
    <gant target="targetC"/>
    <gant target="targetD"/>
    <gant target="targetE"/>
</target>

<target name="-pre-compile">
    <gant target="targetF"/>
</target>


My build.gant file definitely has those targets, but when running build script with Ant I get:

(...)\build.xml:55: java.lang.NoClassDefFoundError: groovy/util/AntBuilder

as soon as Ant hits line:

    <gant target="targetA"/>


I use Groovy 1.8.4 with Gant installed from Windows installer file and Eclipse Helios with Ant view. Gant.dir property has a valid path, so it's not the case. It looks like Groovy can't find targets inside build.gant file even if they are present. I tried even to use Gant task with full path to build.gant file provided, but with no success. The same thing happens when running Ant script from console. Build.gant file is visible in Ant script.

Is there any way to fix this?

Was it helpful?

Solution

So, it was not a problem with invisible targets inside build.gant, but rather with missing libraries in taskdef's classpath. The following fixes my problem:

<path id="gant.libs">
    <fileset dir="${gant.libs.dir}" includes="**/*.jar"/>
</path>

<taskdef name="gant" classname="org.codehaus.gant.ant.Gant">
    <classpath refid="gant.libs"/>
</taskdef>

<target name="-pre-build">
    <gant target="targetA"/>
    <gant target="targetB"/>
    <gant target="targetC"/>
    <gant target="targetD"/>
    <gant target="targetE"/>
</target>

<target name="-pre-compile">
    <gant target="targetF"/>
</target>

where gant.libs.dir refers to a directory containing gant_groovy1.8-1.9.7.jar and groovy-all-1.8.4.jar from Gant 1.9.7 binary standalone installation zip file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top