• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Using ant from my class

 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello there! How can I use ant from my class? let's say:

public void compileMoveandStuffMethod(){
//call ant to process a given build.xml that exists in my application
}

Also, what libs should I add to my app to use this (I just need basic stuff like compile, move, create dirs and etc...)

Regards
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Vinicius,
Since you have a build.xml, you can just call Ant directly. Ant is written in Java, which means you can Ant.main(String[] args) just as you would at the command line. You need the same jars in the classpath as the Ant tutorial suggests for running a build file.
 
Vinicius Carvalho
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually is Launcher.main() hehe!
It's throwing an error saying it can not find my build.xml. I put the complete path as the first argument tough...

Any ideas?
 
Jeanne Boyarsky
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Vinicius,

"Actually is Launcher.main()"
As you can see, I haven't actually done this - just conceptualized about it

"It's throwing an error saying it can not find my build.xml."
Can you reference the build.xml file if you do "new File(args[0)" from you class?
 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can also use Runtime.exec() to call any external app.
 
reply
    Bookmark Topic Watch Topic
  • New Topic