ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matèrne, Jan (RZF, SG 481) <>
Subject AW: RE: Pass build failure message to the calling script
Date Wed, 25 Mar 2015 10:53:14 GMT
Not sure if this would fit your needs:
- write a custome build logger and store the required information in a new file
- check the content of that file


package org.apache.ant;


public class ResultBuildLogger extends DefaultLogger {

    public void buildFinished(BuildEvent event) {

        try(PrintWriter pw = new PrintWriter("build.result")) {
            pw.printf("%s=%s%n", "message", event.getMessage());
            if (event.getException() != null) {
                pw.printf("%s=%s%n", "exception.message", event.getException().getMessage());
        } catch (Exception e) {


<project default="build">

    <property name="build.dir" value="build" />
    <property name="classes.dir" value="${build.dir}/classes" />
    <target name="clean">
        <delete dir="${build.dir}" />
    <target name="build">
        <mkdir dir="${classes.dir}" />
        <javac srcdir="src" destdir="${classes.dir}" includeantruntime="true" />
    <target name="fail1">
        <fail message="This is my error message" />

    exception.message=This is my error message
    <target name="test1">
        <exec executable="cmd.exe">
            <arg line="/K ant.bat -lib ${classes.dir} -logger org.apache.ant.ResultBuildLogger
fail1" />
    exception.message=Compile failed; see the compiler error output for details.
    <target name="fail2">
        <echo>Try to compile invalid java code ...</echo>
        <mkdir dir="${build.dir}/gen-src" />
        <echo file="${build.dir}/gen-src/">
          public class MyClass {}
        <mkdir dir="${build.dir}/gen-classes" />
        <javac srcdir="${build.dir}/gen-src" destdir="${build.dir}/gen-classes" includeantruntime="false"
    <target name="test2">
        <exec executable="cmd.exe">
            <arg line="/K ant.bat -lib ${classes.dir} -logger org.apache.ant.ResultBuildLogger
fail2" />

-----Ursprüngliche Nachricht-----
Von: Al Le [] 
Gesendet: Mittwoch, 25. März 2015 10:40
Betreff: Aw: RE: Pass build failure message to the calling script

> > Is it possible without parsing the output of Ant? If yes, how?
> output="output.html"

But doesn't it essentially mean parsing the build output -- something I'd like to avoid?

I rather thought about Ant setting some kind of an environment variable when it exits. I.e.
I'd specify some option (which probably does not exist yet) on the command line which would
specify the name of a env variable to set, and Ant would set that variable when it exits.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message