This week's book giveaway is in the Testing forum.
We're giving away four copies of Practical Unit Testing with TestNG and Mockito and have Tomek Kaczanowski on-line!
See this thread for details.
The moose likes Ant, Maven and Other Build Tools and the fly likes Launching ant from java code Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Practical Unit Testing with TestNG and Mockito this week in the Testing forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Reply Bookmark "Launching ant from java code" Watch "Launching ant from java code" New topic
Author

Launching ant from java code

Igor Zeta
Ranch Hand

Joined: Nov 12, 2002
Posts: 40
I'm trying to launch an ant statement
that succeed from command line but not
from a java code.
this is what I do from command line

and I get:

init:
[deltree] DEPRECATED - The deltree task is deprecated. Use delete instead.
[deltree] Deleting: D:\igor\work\DBAccessOutput\veicoli\build
[deltree] DEPRECATED - The deltree task is deprecated. Use delete instead.
[deltree] Deleting: D:\igor\work\DBAccessOutput\veicoli\dist
[mkdir] Created dir: D:\igor\work\DBAccessOutput\veicoli\build
compile:
[javac] Compiling 14 source files to D:\igor\work\DBAccessOutput\veicoli\build
[javac] Note: Some input files use or override a deprecated API.
[javac] Note: Recompile with -deprecation for details.
distribution:
[mkdir] Created dir: D:\igor\work\DBAccessOutput\veicoli\dist\lib
[jar] Building jar: D:\igor\work\DBAccessOutput\veicoli\dist\lib\MyProject-20031009.jar
BUILD SUCCESSFUL
Total time: 13 seconds

and this is what I get from java code:

and I get
BuildFile: build.xml does not exist!
or
bad arguments
Any suggestion?


ciao<br />Igor Zeta<br />SCJP1.4
Igor Zeta
Ranch Hand

Joined: Nov 12, 2002
Posts: 40
Great!
I've found the answer my own!
A good happening in a dark day
I've found the answer on the Sun site
Sam Cavenagh
Greenhorn

Joined: Mar 14, 2004
Posts: 1
i went to the link and i didnt like they way ant as called there.
The problem with the way its done above eg

is that your calling the main method so you cant pass in a string you have to pass in an array of strings. The args should have been

i havent tested what is above so in case there is an error ill put what i used below.

hopefully this post can help others with the same problem.
 
IntelliJ Java IDE
 
subject: Launching ant from java code
 
Threads others viewed
Using Ant as a code-generator?
Folder class Path
Ant for Servlets 3b - silly question
Howto run specific JUnit tests in ant?
Debugging MDBs
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com