ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <>
Subject Re: Invoking Ant programmatically with an Java-String
Date Sun, 08 Mar 2009 06:17:54 GMT
On 2009-03-07, Jan Bartel <> wrote:

> Hi everybody,

> I try to invoke ant programmatically.
> At the moment I use the following code to invoke ant from a build.xml:

>     File buildFile = new File("build.xml");
>     Project p = new Project();
>     p.setUserProperty("ant.file", buildFile.getAbsolutePath());
>     p.init();
>     ProjectHelper helper = ProjectHelper.getProjectHelper();
>     p.addReference("ant.projectHelper", helper);
>     helper.parse(p, buildFile);
>     p.executeTarget(p.getDefaultTarget());

> Is there any possibility to invoke ant with an Java-String without using a
> real build.xml ???

Not easily.  Ant's projecthelper implementation wants to read from a
File and you really need a file when you want to resolve relative
paths and so on.

You could write your own ProjectHelper implementation which isn't too
hard to do, but in the end as soon as you want to do anything more
complex in your build file, you'll probably end up writing to a file


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

View raw message