You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Dark Before Dawn <da...@gmail.com> on 2011/06/17 06:31:46 UTC
Programatic ANT: Export Build.xml
Hi there,
I would like to use apache-ant-1.8.2 in JavaSE, to generate build.xml
Files dynamically. Is there a way to export a Project Object as xml File
via Writer/Stream?
CodeSnippet:
Project p = new Project();
p.setName("test");
p.setDefault("test");
Target t = new Target();
t.setName("test");
Echo e = new Echo();
e.setMessage("huhu");
t.addTask(e);
p.addTarget(t);
// export to C:\build.xml
Cheers
Darky
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
RE: Programatic ANT: Export Build.xml
Posted by "Echlin, Robert" <Ro...@windriver.com>.
Hi Darky,
XSLT is a good tool for generating XML files.
Try the free (GPL) version of Saxon, from saxonica.
http://sourceforge.net/projects/saxon/files/
But for help on how to write XSLT, you will have to go to a different list.
Saxon has lists, (and I should subscribe to one.)
Rob
> -----Original Message-----
> From: Dark Before Dawn [mailto:dark.before.dawn@gmail.com]
> Sent: Friday, June 17, 2011 2:29 PM
> To: user@ant.apache.org
> Subject: Re: Programatic ANT: Export Build.xml
>
> Am 17.06.2011 17:13, schrieb Dominique Devienne:
> > On Thu, Jun 16, 2011 at 11:31 PM, Dark Before Dawn
> > <da...@gmail.com> wrote:
> >> I would like to use apache-ant-1.8.2 in JavaSE, to generate build.xml
> >> Files dynamically. Is there a way to export a Project Object as xml
> >> File via Writer/Stream?
> > Nope. And I don't think it's possible (or easy) to do either, at least
> > in the generic case.
> >
> > IMHO you're better off building an in-memory DOM tree for the
> > build.xml and serializing that instead.
> >
> > Ant has no real concept of an AST that'd represent the full build file
> > "info set" like typical compilers, from which it would be easy to
> > "printy print" back to a text file.
> >
> > Thanks, --DD
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For additional
> > commands, e-mail: user-help@ant.apache.org
> >
> >
> At least I got a dynamic/programatic Project object with multiple Targets in
> memory, which I can use to generate WAR Files. I think this is sufficient for
> my tasks :)
>
> Thanks :)
> Darky
>
> ---------------------------------------------------------------------
> 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
Re: Programatic ANT: Export Build.xml
Posted by Dark Before Dawn <da...@gmail.com>.
Am 17.06.2011 17:13, schrieb Dominique Devienne:
> On Thu, Jun 16, 2011 at 11:31 PM, Dark Before Dawn
> <da...@gmail.com> wrote:
>> I would like to use apache-ant-1.8.2 in JavaSE, to generate build.xml Files
>> dynamically. Is there a way to export a Project Object as xml File via
>> Writer/Stream?
> Nope. And I don't think it's possible (or easy) to do either, at least
> in the generic case.
>
> IMHO you're better off building an in-memory DOM tree for the
> build.xml and serializing that instead.
>
> Ant has no real concept of an AST that'd represent the full build file
> "info set" like typical compilers, from which it would be easy to
> "printy print" back to a text file.
>
> Thanks, --DD
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>
At least I got a dynamic/programatic Project object with multiple
Targets in memory, which I can use to generate WAR Files. I think this
is sufficient for my tasks :)
Thanks :)
Darky
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: Programatic ANT: Export Build.xml
Posted by Dominique Devienne <dd...@gmail.com>.
On Thu, Jun 16, 2011 at 11:31 PM, Dark Before Dawn
<da...@gmail.com> wrote:
> I would like to use apache-ant-1.8.2 in JavaSE, to generate build.xml Files
> dynamically. Is there a way to export a Project Object as xml File via
> Writer/Stream?
Nope. And I don't think it's possible (or easy) to do either, at least
in the generic case.
IMHO you're better off building an in-memory DOM tree for the
build.xml and serializing that instead.
Ant has no real concept of an AST that'd represent the full build file
"info set" like typical compilers, from which it would be easy to
"printy print" back to a text file.
Thanks, --DD
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org