ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Nemer <davidne...@gmail.com>
Subject is there exitCode in Ant?
Date Tue, 31 Mar 2009 20:33:34 GMT
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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message