Java Mailing List Archive

Apache Ant Archive

» Ant Users List
» Ant Developers List
Target.getTasks returns UnknownElement

Target.getTasks returns UnknownElement

2007-08-02       - By James Mao


I'm trying to parse the build.xml myself, and tried to get the tasks
object with the following code

       File buildFile = new File("c:/myproject/build.xml");

       Project project = new Project();
       project.setUserProperty( "ant.file" , buildFile.getAbsolutePath());
       project.addBuildListener(new DefaultLogger());
       ProjectHelper.configureProject(project, buildFile);

       Target target = (Target) project.getTargets().get("echome");
       Task[] tasks = target.getTasks();
       System.out.println(((Echo)tasks[0]));   <<< Failure point

The build.xml is

<project name="myproject">
 <target name="echome">
     <echo message="abc"/>

How can i get an instance of Echo , instead of UnknownElement

I'm running the above code inside a junit test

ant 1.7.0, junit4, jdk1.6

Thanks in advance!

To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

©2008 - Jax Systems, LLC, U.S.A.