• 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

Running ant from java program with dynamic build.xml

 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
Can we call ant from inside a java program with dynamically generated build xml in a string representation or other; (do not want to store it in temp file too... )
Thanks for your time,
 
Chandra Peri
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry for the stupid question. Hmm! it was clearly mentioned in the documentation that we can use any task inside a java program.
 
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey, sometimes we think out loud
 
Author
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Quick answer, yes, you can call ANT from inside your Java program. <shameless plus>In chapter 9 of our book, you'll find some source that will show you how to configure a project so that you can execute it.</shameless plug>
 
Leslie Chaim
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just wondering, didn't Chandrakumar properly correct himself with his second post? It appears Kirk that "Chapter 9" has something to add :roll:
And what is the plug?
 
Chandra Peri
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually, I wanted to use the FTP task of Ant inside my java program. As metioned in my last post, didn't check the docs thoroughly, and I completed using apache's commons-net library. So I did not jump into Ant further...

 
Kirk Pepperdine
Author
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Chandrakumar,
Given that you just want to reuse code and that just happens to be embedded in ANT, then your solution of using code from commons is a better approach. FYI, the code would look something like...

HTH
 
Chandra Peri
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Kirk!
But I was having different implementation in my mind, after I looked at the docs.
As I mentioned in my original post, I wanted to use without build file. As I understand, a build file is needed in your example.( I sure don't want to be picky, just trying to get the most...)
I would have tried with the FTP (task) api directly, by providing necessary values using setters and initializing with a default Project and a Target.
Do you foresee any issues?
Chandrakumar
 
Kirk Pepperdine
Author
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, you are correct, a build file is needed. HST, if you only want to ftp, then commons is probably the best place to look for a component. No point in dragging around the entire framework for a single feature
 
Chandra Peri
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well said!
reply
    Bookmark Topic Watch Topic
  • New Topic