ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gerry Healy <>
Subject Running ant from the API
Date Tue, 15 Aug 2006 14:59:06 GMT
Hi there,

I am having trouble using third party ant tasks, with nested elements, 
from the Ant API. For example the ant-contrib IfTask and the svnant 

I am able to use both of these tasks in build scripts without a problem, 
when running ant from the command line. But I want to use them from the 
Ant API. However when I do this with Ant 1.6.0 I get an error similar to 
below, which is clearly not correct:

 build.xml:215: Class net.sf.antcontrib.logic.IfTask doesn't support the 
nested "equals" element.

With Ant 1.6.5 I get:

 build.xml:215: java.lang.NullPointerException

I'm running:

RedHat 9
Java 1.4.2 (build 1.4.2_03-b02)
Ant 1.6.0 (compiled on December 18 2003)  and 1.6.5 (compiled on June 2 

Below is some sample code and a link to a working (but broken) project 
that demonstrates the problem.

Any help would be appreciated. Thanks,



The section of the build that is failing is trivial:

    <equals arg1="yes" arg2="no" />
      <echo message="same"/>
      <echo message="different"/>

And the taskdef is declared as below:

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

I've also tried the following declarations, which makes no difference

<taskdef resource="net/sf/antcontrib/antlib.xml">
    <pathelement location="/full/path/to/ant-contrib.jar" />

<taskdef name="svn" classname="net.sf.antcontrib.logic.IfTask">
  <classpath refid="antlib.classpath" />

The relevent API code is:

String buildFile = "/path/to/build/file";
String buildDir = "/path/to/build/dir";

try {


  project.setBaseDir( new File( buildDir ));
  project.setUserProperty( "ant.file", buildFile);
  project.setUserProperty( "ant.version", Main.getAntVersion());

  ProjectHelper projHelper = new ProjectHelperImpl();
  projHelper.parse(project, new File(buildFile));
  project.executeTarget( target );

} catch( Throwable ex) {

  error = ex;              
} finally {




build.xml: buids AntTest.class runs AntTest, which uses Ant API
anttest.xml: build file  used by
to build:
# ant

to run:
# ./

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message