You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Robert Koberg <ro...@koberg.com> on 2004/01/29 17:04:38 UTC

Re: howto trigger an Ant build within java

[moving to dev list]

Jim Fuller wrote:

>>From: Robert Koberg [mailto:rob@koberg.com] 
>>Sent: 29 January 2004 02:49
>>To: user@ant.apache.org
>>Subject: howto trigger an Ant build within java
> 
> 
>>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).
> 
> 
> So the transformation of config file is happening in your app which
> ultimately generates a build file, which in turn you would like to
> simply run ant on ?

The configs are held in memory(jdom) and eventually I would like to use 
/something/ like a chained transformation to go from the configs to an 
ant build in memory and run the build on a user chosen target.  I would 
use the build file to present a 'nav' tree similar to what eclipse does. 
The user clicks on a target to do things like generate a 
site/folder/page or promote to a vhost stage (local or remote) based on 
their config.


> 
> 
>>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 
> 
> 
> Hello Rob,
> 
> If you are physically generating the build file then just use the
> launcher in the
> http://nagoya.apache.org/gump/javadoc/ant/build/javadocs/index.html
> org.apache.tools.ant.launch package. Though perhaps you want more
> control 

yes, more control

> 
> Which is where I can highly recc the use of jelly
> http://jakarta.apache.org/commons/jelly/

I will look into this.

> 
> I have found that there are some 'gotchas' with such dynamic
> instantiation and running of a build direct from ant api, though this
> could be down to my own limited knowledge.

Yes, I have seen some warnings on this. I was hoping there would be a 
way to do this with ant and still be safe. I will move this to the dev 
list and see if someone there can help.

best,
-Rob

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


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