ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ultra Funkular <funku...@nettaxi.com>
Subject AntStructure differences between api and buildfile usage
Date Wed, 19 Jun 2002 01:03:23 GMT
Stephen Bodewig (and anyone else),

The output file of the antstructure task varies hugely depending on how it 
was invoked.

If invoked through the api directly, then taskdefs must be added to the 
project instance for dtd information on those classes to be generated.
	try
	{
                 Project project = new Project();
                 Target target = new Target();
                 AntStructure task = new AntStructure();  // 
(AntStructure) project.createNewTask("antstructure");
		try
		{
  			project.addTaskDefinition( "javac", Class.forName( 
"org.apache.tools.ant.taskdefs.javac") );
		}
		catch(Exception e)
		{
		}
		File file = new File("ant2.dtd");
                 task.setOutput( file );
                 target.addTask( task );
                 final String TARGET_NAME = "CreateDTD";
                 target.setName(TARGET_NAME);
                 project.addTarget(TARGET_NAME, target);
                 project.executeTarget(TARGET_NAME);

	}
	catch(BuildException be)
	{
	}



In contrast, if a build file were to simply be:

<?xml version="1.0" encoding="UTF-8" ?>
<project default="dtd"
     name="test"
     basedir="../">
     <target name="dtd">
         <antstructure output="ant2.dtd"/>
     </target>
</project>

Then every task existing in the ant.jar and optional.jar has their DTD 
information generated.  I love this!



How may I achieve the same result using the api?
the workaround is to output a build.xml file, then run ExecOn on it...


All help appreciated :)


Regards,

T Master



--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message