Grokbase Groups Ant user March 2009
FAQ
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 ???

Thank you for your suggestions

CU
Jan





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

Search Discussions

  • Stefan Bodewig at Mar 8, 2009 at 6:18 am

    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
    anyway.

    Stefan

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org
  • Jan Bartel at Mar 9, 2009 at 8:29 am
    Hi Stefan and Gilbert, thank you for your help :-)

    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.:t
    I suppose reimplementing the projecthelper would fit my requirements .
    Isn't there a way to set the basedir manually (programatically or with a tag) to cope with the problem of relative paths.
    if you want to use Ant without xml you may try ....
    leafcutter and groovy/AntBuilder seem to be very powerful libraries but at the moment I have to focus on XML ....

    Thank you
    Jan




    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org
  • Gilbert Rebhan at Mar 8, 2009 at 10:26 am

    Jan Bartel schrieb:
    Is there any possibility to invoke ant with an Java-String without using a
    real build.xml ???
    if you want to use Ant without xml you may try =

    1.Groovy / AntBuilder
    http://groovy.codehaus.org/Ant+Integration+with+Groovy
    or
    2.Leafcutter
    https://leafcutter.dev.java.net/


    Regards, Gilbert

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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupuser @
categoriesant
postedMar 7, '09 at 8:58p
activeMar 9, '09 at 8:29a
posts4
users3
websiteant.apache.org

People

Translate

site design / logo © 2017 Grokbase