Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to call a build.xml

 
Meet Gaurav
Ranch Hand
Posts: 492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

How to to call or execute a build.xml (ant file) from a simple java program.
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java.lang.Runtime
 
Ove Lindström
Ranch Hand
Posts: 326
Android Firefox Browser Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You use the Ant.class from the Ant API and load your build.xml using the setAntFile(String fileName) and then use .execute();
 
Meet Gaurav
Ranch Hand
Posts: 492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is not working...

 
Tom Johnson
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is the file in the appropriate place? From the Ant docs:
public void setAntfile(java.lang.String s)
The build file to use. Defaults to "build.xml". This file is expected to be a filename relative to the dir attribute given.


You can use the following method to set the directory:

public void setDir(java.io.File d)

The directory to use as a base directory for the new Ant project. Defaults to the current project's basedir, unless inheritall has been set to false, in which case it doesn't have a default value. This will override the basedir setting of the called project.


HTH
[ December 05, 2008: Message edited by: Tom Johnson ]
 
Ove Lindström
Ranch Hand
Posts: 326
Android Firefox Browser Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Meet Gaurav:
This is not working...



Hey... I pointed you in the right direction... not giving you the whole answer...

Yes, you have to set the running directory with obj.setDir("dir-path");
 
Campbell Ritchie
Sheriff
Pie
Posts: 48970
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not a beginner's topic. Moving thread.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic