ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Al Le <al...@gmx.de>
Subject Re: Pass build failure message to the calling script
Date Wed, 25 Mar 2015 20:18:29 GMT
Thank you for the hint! That would be probably the simplest solution. 
There seems to be no solution without parsing some kind of file.


Am 25.03.2015 um 11:53 schrieb Matèrne, Jan (RZF, SG 481):
> 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
>
> Jan
>
>
> package org.apache.ant;
>
> import org.apache.tools.ant.*;
> import java.io.*;
>
> public class ResultBuildLogger extends DefaultLogger {
>
>      public void buildFinished(BuildEvent event) {
>          super.buildFinished(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>
>
>      <target name="build">
>          <mkdir dir="${classes.dir}" />
>          <javac srcdir="src" destdir="${classes.dir}" includeantruntime="true" />
>      </target>
>
>      <target name="fail1">
>          <fail message="This is my error message" />
>      </target>
>
>      <!--
>      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" />
>          </exec>
>      </target>
>
>      <!--
>      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/MyClass.java">
>            import org.apache.commons.io.IOUtils;
>            public class MyClass {}
>          </echo>
>          <mkdir dir="${build.dir}/gen-classes" />
>          <javac srcdir="${build.dir}/gen-src" destdir="${build.dir}/gen-classes" includeantruntime="false"
/>
>      </target>
>
>      <target name="test2">
>          <exec executable="cmd.exe">
>              <arg line="/K ant.bat -lib ${classes.dir} -logger org.apache.ant.ResultBuildLogger
fail2" />
>          </exec>
>      </target>
>
>
> </project>
>
>
> -----Ursprüngliche Nachricht-----
> Von: Al Le [mailto:Al.Le@gmx.de]
> Gesendet: Mittwoch, 25. März 2015 10:40
> An: user@ant.apache.org
> 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: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message