You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Jay Glanville <di...@nortelnetworks.com> on 2000/11/20 13:49:16 UTC

How to force ant to continue after build failure?

In my build file, I want to mail the results of the build to the loadbuild
manager regardless of success or fail.  Therefore, I naively made a
build.xml file that looks like this:

  <target name="compile" depends="init" >
    <recorder file="compile.output" recording="on" />
    <javac .../>
    <recorder file="compile.output" recording="off" />
  </target>

  <target name="notify" >
    <mail files="compile.output" ... />
  </target>

  <target name="formal_loadbuild"
      depends="compile,notify" >
  </target>

(the <recorder> task is one that I created.  It simply adds a build listener
to the project, recording all events to the stated file.  If people like, I
will clean it up and submit it for possible future inclusion.)

The reason that I use the word naivety is because I forgot that if the javac
task fails, then the build process stops.  This means that my loadbuild
manager doesn't get notified of loadbuild failures.  Is there a "magic"
property that I can set to force ant to continue after build failures?  

Do I have other options?  I know that I could have two build files, one for
the <javac> task that actually does the work, and the other for the
formal_loadbuild target that uses an <ant> task to run the javac and then
mails the results.  Something like this:
--- inner_build.xml ---
  ...
  <target name="compile" depends="init" >
    <javac ... />
  </target>
  ...
--- inner_build.xml ---
--- build.xml ---
  ...
  <target name="formal_loadbuild" >
    <ant antfile="inner_build.xml" 
      target="compile"
      output="compile.output" />
    <mail files="compile.output" .../>
  </target>
--- build.xml ---
The reason I don't like this is because I'm now having to maintain two
separate build files for one build process.  By extension, I now need to
completely isolate my compile task from all the tasks that depend on it.

Do I have other options then the one mentioned above?

Thanks for the replies I hope I get  =>


Jay

PS: I've searched the e-mail archives, but I've found no answer to my
question, only the same question asked by other people.

----------------------------------------------------------------------------
-----
Jay Dickon Glanville
P068 - SiteManager Development, Nortel Networks
613-765-1144 (ESN 395-1144)
MS: 045/55/A05
E-Mail: dickon@nortelnetworks.com


Re: How to force ant to continue after build failure?

Posted by Stefan Bodewig <bo...@apache.org>.
Jay Glanville <di...@nortelnetworks.com> wrote:

> In my build file, I want to mail the results of the build to the
> loadbuild manager regardless of success or fail.

Jay, take a look at
<http://jakarta.apache.org/jyve-faq/Turbine/screen/DisplayQuestionAnswer/action/SetAll/project_id/2/faq_id/16/topic_id/196/question_id/741>.

Basically, attach a build listener and send your mail in
buildFinished. To closer model

>   <target name="compile" depends="init" >
>     <recorder file="compile.output" recording="on" />
>     <javac .../>
>     <recorder file="compile.output" recording="off" />
>   </target>

The build listener could send its mail either in buildFinished or when
the task with recording="off" gets executed - whatever happens first.

> Is there a "magic" property that I can set to force ant to continue
> after build failures?

Adding some "make -k" like functionality to Ant has been on the TODO
list for quite some time now, but it's quite far towards the end (of
my private version).

> PS: I've searched the e-mail archives, but I've found no answer to
> my question, only the same question asked by other people.

Given that there is a FAQ entry for the functionality you want (feel
free to ad a version using org.apache.tools.mail instead of javamail
if you happen to write one BTW, yet another point from my TODO list)
...

I'm sure, I've pointed others to the FAQ on this before - and Will has
sent his code to this group, so you must have searched for the wrong
keywords 8-).

Stefan