Launching ant through java code
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   igor_zerbesi
Posted On:   Monday, October 13, 2003 12:46 AM

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 ant -l D:/log.log -f D:igorworkDBAccessOutputveicoli/App_Name.xml and I get: init: [deltree] DEPRECATED - The deltree task is deprecated. Use delete instead. [deltree] Deleting: D:igorworkDBAccessOutputveicoli uild [deltree] DEPRECATED - The deltree task is deprecated. Use delete instead. [deltree] Deleting: D:igorworkDBAccessOutputveicolidist [mkdir] Created dir: D:igorworkDBAccessOutputveicoli uild compile: [javac] Compiling 14 source files to D:igorworkDBAccessOutputveicoli uild   More>>

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



ant -l D:/log.log -f D:igorworkDBAccessOutputveicoli/App_Name.xml





and I get:


init:
[deltree] DEPRECATED - The deltree task is deprecated. Use delete instead.
[deltree] Deleting: D:igorworkDBAccessOutputveicoli uild
[deltree] DEPRECATED - The deltree task is deprecated. Use delete instead.
[deltree] Deleting: D:igorworkDBAccessOutputveicolidist
[mkdir] Created dir: D:igorworkDBAccessOutputveicoli uild
compile:
[javac] Compiling 14 source files to D:igorworkDBAccessOutputveicoli uild
[javac] Note: Some input files use or override a deprecated API.
[javac] Note: Recompile with -deprecation for details.

distribution:
[mkdir] Created dir: D:igorworkDBAccessOutputveicolidistlib
[jar] Building jar: D:igorworkDBAccessOutputveicolidistlibMyProject-20031009.jar

BUILD SUCCESSFUL
Total time: 13 seconds






and this is what I get from java code:


org.apache.tools.ant.Main.main("-l D:/log.log -f D:igorworkDBAccessOutputveicoli/App_Name.xml");but also... org.apache.tools.ant.Main.main("ant -l D:/log.log -f D:igorworkDBAccessOutputveicoli/App_Name.xml");





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




Another question I've been asking myself is why after the execution of ant ends my swing gui program exit?

Any suggestion on how to avoid any ant System.exit()?


Please give me some Chink of light!

Igor Z.    <<Less

Re: Launching ant through java code

Posted By:   Ionescu_Victor  
Posted On:   Wednesday, October 22, 2003 06:45 AM

To prevent your app from exit after done with ant,you must


write a NoExitSecurityManager class.


In fact I wrote such stuff recently and I can sent you


a zip with about 3 java files I used to call ant from a


swing application. Send me an email at


vionescu@toptech-software.com and you'll get the job done.

Re: Launching ant through java code

Posted By:   Vojto_Balint  
Posted On:   Wednesday, October 22, 2003 06:21 AM

Hi,
I suppose that arguments for main method should be formatted
as an array of string, e.g.:

String[] args = new String[4];

args[0] = "-buildfile";

args[1] = "//home//project//prg//build.xml";

args[2] = "-DmyProp=XXX";

args[3] = "all;

org.apache.tools.ant.Main.main(args);


API documentation for ant (class org.apache.tools.ant.Main) contains sentence:
"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." I suppose, that this is the reason why your program terminates.

Vojto

About | Sitemap | Contact