• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Call ant script through java file

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I have a requirement to run the ant script through a button on jsp.
My question would be can i run the ant build.xml through java code if yes they how??
Thanks in advance
Regards
 
Ranch Hand
Posts: 442
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I cant think of a better or other solution for this right now, but one way to do it would be to use Runtime.exec("cmd ant someTarget")
 
Ta Ri Ki Sun
Ranch Hand
Posts: 442
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
oh yes, you could also look at calling "org.apache.tools.ant.Main %ANT_CMD_LINE_ARGS%" yourself.
 
Anubhuti Bhargava
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you give a small example as it is not working.
regards
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The javadoc for org.apache.tools.ant.Main says the following:
If you integrating Ant into some other tool, this is not the class to use as an entry point. Please see the source code of this class to see how it manipulates the Ant project classes.
So, I guess you should grab the Ant source distribution and see for yourself. From a quick glance, I think this should be enough:
 
Ta Ri Ki Sun
Ranch Hand
Posts: 442
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Lasse Koskela:
The javadoc for org.apache.tools.ant.Main says the following:
If you integrating Ant into some other tool, this is not the class to use as an entry point. Please see the source code of this class to see how it manipulates the Ant project classes.
So, I guess you should grab the Ant source distribution and see for yourself. From a quick glance, I think this should be enough:


Lasse you have a good point, well spotted, I didn't look at those docs at all, anyhat, you've also overlooked a few things, one is that Main has protected access and also runBuild has private access, lastly I interpret that javadoc to mean dont use this class at all, look at the classes it manipulates, such as Project.
So Anubhuti, you now need to read some source code.
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well spotted to you too
 
You’ll find me in my office. I’ll probably be drinking. And reading this tiny ad.
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic