Hey guys, I got the integration with Ant and Java working fine.
I was wondering if Ant has something like getExitCode() that tells you if it was successful in building whatever the build.xml was supposed to, just like in Maven. How would I add it to my code? private static void antCaller(){ File buildFile = new File("C:\\test\\build.xml"); Project p = new Project(); p.setUserProperty("ant.file", buildFile.getAbsolutePath()); DefaultLogger consoleLogger = new DefaultLogger(); consoleLogger.setErrorPrintStream(System.err); consoleLogger.setOutputPrintStream(System.out); consoleLogger.setMessageOutputLevel(Project.MSG_INFO); p.addBuildListener(consoleLogger); try { p.fireBuildStarted(); p.init(); ProjectHelper helper = ProjectHelper.getProjectHelper(); p.addReference("ant.projectHelper", helper); helper.parse(p, buildFile); p.executeTarget(p.getDefaultTarget()); p.fireBuildFinished(null); } catch (BuildException e) { p.fireBuildFinished(e); } } Thank you once again, Cheers, -- David Nemer Sent from: Kaiserslautern RP Germany. On Wed, Mar 18, 2009 at 8:54 PM, Matt Benson <gudnabr...@yahoo.com> wrote: > > Here's one: http://tinyurl.com/jz76f > > -Matt > > --- On Wed, 3/18/09, David Nemer <davidne...@gmail.com> wrote: > > > From: David Nemer <davidne...@gmail.com> > > Subject: Re: Developing in Java with ANT > > To: "Ant Users List" <user@ant.apache.org> > > Date: Wednesday, March 18, 2009, 2:31 PM > > Do you guys by any chance know any > > open source project that runs its test > > scripts with Ant?? > > > > Thanks > > -- > > David Nemer > > Sent from: Kaiserslautern RP Germany. > > > > On Wed, Mar 18, 2009 at 6:57 PM, David Nemer <davidne...@gmail.com> > > wrote: > > > > > Thanks Matt!! Now it works ;) > > > -- > > > David Nemer > > > Sent from: Kaiserslautern RP Germany. > > > > > > On Wed, Mar 18, 2009 at 6:51 PM, Matt Benson <gudnabr...@yahoo.com> > > wrote: > > > > > >> > > >> You need to include ant-launcher.jar to get the > > AntMain interface. This > > >> probably should be in the core Ant jar but would > > take a little refactoring. > > >> We'll keep it in mind for 1.8.0. > > >> > > >> -Matt > > >> > > >> --- On Wed, 3/18/09, David Nemer <davidne...@gmail.com> > > wrote: > > >> > > >> > From: David Nemer <davidne...@gmail.com> > > >> > Subject: Re: Developing in Java with ANT > > >> > To: "Ant Users List" <user@ant.apache.org> > > >> > Date: Wednesday, March 18, 2009, 12:38 PM > > >> > Hey, everyone, thank you for you > > >> > help. > > >> > > > >> > I stick with the solution from Gawor ( > > >> > > > >> > http://www.ibm.com/developerworks/websphere/library/techarticles/0502_gawor/0502_gawor.html > > >> > ): > > >> > > > >> > File buildFile = new File("build.xml"); > > >> > Project p = new Project(); > > >> > p.setUserProperty("ant.file", > > >> > buildFile.getAbsolutePath()); > > >> > p.init(); > > >> > ProjectHelper helper = > > ProjectHelper.getProjectHelper(); > > >> > p.addReference("ant.projectHelper", helper); > > >> > helper.parse(p, buildFile); > > >> > p.executeTarget(p.getDefaultTarget()); > > >> > > > >> > It seems pretty simple, but when it tries to > > run the > > >> > "p.init();" I get the > > >> > following error: > > >> > > > >> > Exception in thread "main" > > java.lang.NoClassDefFoundError: > > >> > org/apache/tools/ant/launch/AntMain > > >> > at > > java.lang.ClassLoader.defineClass1(Native > > >> > Method) > > >> > at > > java.lang.ClassLoader.defineClass(Unknown > > >> > Source) > > >> > at > > >> > > > java.security.SecureClassLoader.defineClass(Unknown Source) > > >> > at > > >> > java.net.URLClassLoader.defineClass(Unknown > > Source) > > >> > at > > java.net.URLClassLoader.access$000(Unknown > > >> > Source) > > >> > at > > java.net.URLClassLoader$1.run(Unknown > > >> > Source) > > >> > at > > >> > > > java.security.AccessController.doPrivileged(Native Method) > > >> > at > > java.net.URLClassLoader.findClass(Unknown > > >> > Source) > > >> > at > > java.lang.ClassLoader.loadClass(Unknown > > >> > Source) > > >> > at > > >> > > > sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) > > >> > at > > java.lang.ClassLoader.loadClass(Unknown > > >> > Source) > > >> > at > > >> > > > java.lang.ClassLoader.loadClassInternal(Unknown Source) > > >> > at > > >> > > > org.apache.tools.ant.Project.initProperties(Project.java:308) > > >> > at > > >> > > > org.apache.tools.ant.Project.init(Project.java:295) > > >> > at > > testAnt.main(testAnt.java:14) > > >> > > > >> > > > >> > THis line 14 refers to p.init(); > > >> > > > >> > Do you guys have any clues what it might > > be?? > > >> > > > >> > > > >> > -- > > >> > David Nemer > > >> > Sent from: Kaiserslautern RP Germany. > > >> > > > >> > On Tue, Mar 17, 2009 at 9:42 AM, Felix Dorner > > <fdor...@zed.com> > > >> > wrote: > > >> > > > >> > > > > >> > > Whoops > > >> > > > > >> > > > Maybe you look for something like > > this: > > >> > > > > >> > > > > >> > > > > >> > http://www.ibm.com/developerworks/websphere/library/techarticles/0502_gawor/0502_gawor.html > > >> > > > > >> > > Felix > > >> > > > > >> > > > > >> > > > --------------------------------------------------------------------- > > >> > > To unsubscribe, e-mail: user-unsubscr...@ant.apache.org > > >> > > For additional commands, e-mail: user-h...@ant.apache.org > > >> > > > > >> > > > > >> > > > >> > > >> > > >> > > >> > > >> > > --------------------------------------------------------------------- > > >> To unsubscribe, e-mail: user-unsubscr...@ant.apache.org > > >> For additional commands, e-mail: user-h...@ant.apache.org > > >> > > >> > > > > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@ant.apache.org > For additional commands, e-mail: user-h...@ant.apache.org > >