ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Koberg <>
Subject [Fwd: howto trigger an Ant build within java]
Date Thu, 29 Jan 2004 16:07:19 GMT

I am looking into using Ant (v1.6.0) more in my webapp so I can offer
offline publishing equivalents. I am transforming some config XML into a
build file. I then want to load that build file into a new The build.xml gets produce properly (it
runs successfully from the command line).

How do I load the build file and create an ant project, then trigger a
particular target to execute? The build file uses only Core Tasks (and
an xmlcatalog). Is there a simple example somewhere? I have tried
searching with google but getting too many hits that don't cover what I
am looking for.

Here is what I have tried: antProject = new;

AntXMLContext antContext = new AntXMLContext(antProject);

File f = lsbProject.lookup("build.xml").getFile();
System.out.println("build.xml: " + f);

System.out.println("project name: " + antContext.getCurrentProjectName());

Vector targets = antContext.getTargets();
for (Enumeration e = targets.elements(); e.hasMoreElements();) {
   Target target = (Target) e.nextElement();
System.out.println(target.getName() + " : " + target.getDescription());

the System.outs produce:

build.xml: c:\home\app\projects\grok\build.xml
project name: null
  : null

thanks for any help,

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

View raw message