----- Original Message -----
From: "Stefan Bodewig" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, September 25, 2000 5:58 PM
Subject: <require>, <fail unless="..."> or <available fail="...">
> All of these suggestions are there to shorten the <available>, <target
> unless>, <fail> combo necessary to achieve the same effect. I'd like
> to see us settle on one and only one approach. Perl's "there's is more
> than one way to do it" does not exactly fit into my picture of Ant.
>
> Personally I'm not really decided between <require> and <fail
> unless>. The first one saves one takes the second one might be useful
> in a broader range of use cases where available does not apply.
>
I would generally say you are right with your assumptions, but in these
cases I think it's a bit overhead (not to mention that I would not name it a
target in my build to fail if something is wrong) to create a number of
targets just to make sure everything else will work correctly in the build
process?
Currently you must use (if there isn't a better way I can't think of)
something like the following to check for existence of a file and
discontinue work if it isn't there.
<target name="do-the-work" depends="test-prepare,test-execute">
<echo message="All right"/>
</target>
<target name="test-prepare" depends="test-prepare">
<available file="myrequiredfile" property="itsthere"/>
</target>
<target name="test-execute" unless="itsthere">
<fail message="File is missing"/>
</target>
Ot something like this
<target name="do-the-work" depends="test-property1,test-property2">
<echo message="All right"/>
<property name="foo" value="${prop1}/something"/>
<property name="bar" value="${prop2}/somethingelse"/>
</target>
<target name="test-propert1" unless="prop1">
<fail message="prop1 is not set"/>
</target>
<target name="test-propert2" unless="prop2">
<fail message="prop2 is not set"/>
</target>
only to validate that two properties are set (may get harder if you want to
check if they are set to a valid value...)
With fail and if/unless attributes you can do all of the above in a easy
understandable way. What does 'available fail="..' mean? Fail if something
is available? Fail if not? Sure, you need to define two tasks, but everyone
should understand that you test if something is available, set a property if
it is and fail unless it's available (or fail if it's available).
Nico