ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yyy Xxx <gj...@yahoo.com>
Subject Re: Suggestions for documentation & exec
Date Fri, 19 Oct 2001 17:48:24 GMT
Thank you, Phil, for your outputproperty example.  But
I'm actually looking for an "rcproperty" attribute. 
I'd like to have the return code of the exec made
visible to ant.

For instance, suppose I exec a program and want to
take action if the program fails.  I could use the
failonerror attribute and have the ant build fail. 
But it would be better if I could fail more
gracefully.

Here's a made-up example.  The Unix diff program exits
with a status(return) code of 0 if two files are the
same, 1 if some differences were found, and 2 means
trouble.

The "diff" target causes diff to be run against two
files.  The (made up) rcproperty attribute would
capture the status code and let <condition> analyze
it.
When diff returned a status code of "2", ant would
automatically e-mail me a note before failing.

<target name='rundiff'>
  <exec executable='diff' rcproperty='diff.rc'>
     <arg value='${file1}'/>
     <arg value='${file2}'/>
  </exec>

  <condition property='diff.failed'>
    <equals arg1='${diff.rc}' arg2='2'/>
  </condition>
</target>

<target name='check-diff' depends='rundiff'
if='diff.failed'>
  <mail subject='*** DIFF Failed ***' message='A diff
of ${file1} and ${file2} is giving us trouble.'/>
  <fail/>
</target>

<target name="diff" depends='check-diff'/>





Phil Surette wrote:
> As for your last point, (6), not sure if you're
> citing this as a commonly asked question, or as
> an actual limitation of ant. Just in case, you
> can save the output of an exec using the
> outputproperty attribute...

Yyy Xxx wrote:
>> And (6), I'd like to have a way to store the return
>> code of an <exec> in a property.  I'd like to
>> conditionally execute tasks based on the return
>> code of an exec'd program.  My only choice seems
>> to use the "failonerror" attribute, but I don't
>> want to fail my ant.

__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com

Mime
View raw message