ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Dawson <tdaw...@wamnet.com>
Subject proposed <fail> enhancement (implementation attached)
Date Tue, 20 Mar 2001 14:57:50 GMT
Hello,

I'd like to submit a change for Ant 1.4 to add "if" and "unless" attributes
to the <fail> task, and also to allow the fail task to contain a body, much
like the <echo> task.  These changes come in very handy in conjunction with
<available> to ensure that required files are present. Currently one must
use multiple targets to accomplish what should be relatively simple, e.g.

  <target name="init">
    [...]
    <available property="junit.available"
               file="${junit.jar}" />
    [...]
  </target>

  <target name="checkJUnit" unless="junit.available">
    <fail message="junit was not found. please set a JUNIT_JAR environment
variable, or override junit.jar in your buildconfig-local properties file.
download junit from www.junit.org if necessary." />
  </target>

Anything that wants to ensure that junit has been provided must depend on
BOTH init and checkJUnit. This gets even more messy when there's a laundry
list of things that are required.

By adding "if" and "unless", you can make this quite simple:

  <target name="init">
    [...]
    <available property="junit.available"
               file="${junit.jar}" />
    <fail unless="junit.available">
        junit was not found. please set a JUNIT_JAR environment variable,
        or override junit.jar in your buildconfig-local properties file.
        download junit from www.junit.org if necessary.
    </fail>
    [...]
  </target>

Also note how much nicer it is to have the text of the fail message inside
the tag when you have long multiline messages to display!

I'm not an ANT committer, so I'd like to ask someone who is to please
consider this submission and include it in the 1.4 tree if nobody rasies any
objections.

Thanks,

Tim Dawson
Chief Software Architect
WAM!NET, Inc.


Mime
View raw message