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

Reply via email to