ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From supp...@boutell.com (Support Staff)
Subject Re: howto trigger an Ant build within java
Date Thu, 29 Jan 2004 02:54:04 GMT
Thank you for contacting Boutell.Com Technical Support!

PLEASE NOTE: OUR SUPPORT EMAIL ADDRESSES HAVE BEEN REPLACED. They have
been replaced by our new support page:

http://www.boutell.com/contact/

This step is necessary to control the volume of unsolicted "spam"
our staff receives on a daily basis.

YOUR MESSAGE WILL NOT BE DELIVERED, unless you visit the page
mentioned above. For your convenience, the text of your message
is appended. Please visit the page above and copy and paste
your message text there. We apologize sincerely for the
inconvenience.

Thank you for your understanding!

- Thomas Boutell and the staff of Boutell.Com, Inc.

** YOUR ORIGINAL MESSAGE FOLLOWS -- it has NOT BEEN RECEIVED --
** please visit http://www.boutell.com/contact/ and copy and paste
** your message there

Hi,

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 
org.apache.tools.ant.Project. 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:

org.apache.tools.ant.Project antProject = new 
org.apache.tools.ant.Project();

AntXMLContext antContext = new AntXMLContext(antProject);

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

antContext.setBuildFile(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,
-Rob

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


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


Mime
View raw message