You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Rosenbaum, Thomas" <Th...@harley-davidson.com> on 2005/10/06 23:19:10 UTC
Clarification - unless and/or if
Hello,
I am using Ant 1.6.5 - can multiple properties be specified in the "if"
or "unless" attributes of a given target?
<available file="file.ext" property="prop1"/>
<available file="file2.ext" property="prop2"/>
<available file="file3.ext" property="prop3"/>
<available file="file4.ext" property="prop4"/>
<target name="blah" if="prop1,prop2"> ... </target>
<target name="blahblah" unless="prop3,prop4"> ... </target>
If so, is the relationship an "or" or an "and"?
If this is not possible, what is the best practice for executing a
target if multiple conditions are met? I could do the following, but I
end up creating all kinds of extra/throw-away properties:
<condition property="exec-target1">
<and>
<available file="file.ext" property="prop1"/>
<available file="file2.ext" property="prop2"/>
</and>
</condition>
<condition property="do-not-exec-target1">
<and>
<available file="file3.ext" property="prop3"/>
<available file="file4.ext" property="prop4"/>
</and>
</condition>
<target name="blah" if="exec-target1"> ... </target>
<target name="blahblah" unless="do-not-exec-target1"> ...
</target>
Can anyone help clear this up for me?
Many thanks!
- Tom
Re: Clarification - unless and/or if
Posted by Dominique Devienne <dd...@gmail.com>.
> I am using Ant 1.6.5 - can multiple properties be specified in the "if"
> or "unless" attributes of a given target?
No.
> If this is not possible, what is the best practice for executing a
> target if multiple conditions are met? I could do the following, but I
> end up creating all kinds of extra/throw-away properties:
Right.
Some people like to use Ant-Contrib's <if> task that takes a condition
directly, no need for a property, but you don't have 2 or more targets
anomore, but different branches inside a single target (or the
top-level), which may no fit your need.
I personnally use a custom if-like sequential that behave more like
XSL's <if> (no else branch) than Ant-Contrib's if (if then [else]),
and not that often.
--DD
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: Clarification - unless and/or if
Posted by Matt Benson <gu...@yahoo.com>.
The approach you show below is "approved."
-Matt
--- "Rosenbaum, Thomas"
<Th...@harley-davidson.com> wrote:
> Hello,
>
> I am using Ant 1.6.5 - can multiple properties be
> specified in the "if"
> or "unless" attributes of a given target?
>
> <available file="file.ext" property="prop1"/>
> <available file="file2.ext" property="prop2"/>
> <available file="file3.ext" property="prop3"/>
> <available file="file4.ext" property="prop4"/>
>
> <target name="blah" if="prop1,prop2"> ... </target>
> <target name="blahblah" unless="prop3,prop4"> ...
> </target>
>
> If so, is the relationship an "or" or an "and"?
>
> If this is not possible, what is the best practice
> for executing a
> target if multiple conditions are met? I could do
> the following, but I
> end up creating all kinds of extra/throw-away
> properties:
>
> <condition property="exec-target1">
> <and>
> <available file="file.ext" property="prop1"/>
> <available file="file2.ext" property="prop2"/>
> </and>
> </condition>
> <condition property="do-not-exec-target1">
> <and>
> <available file="file3.ext" property="prop3"/>
> <available file="file4.ext" property="prop4"/>
> </and>
> </condition>
> <target name="blah" if="exec-target1"> ...
> </target>
> <target name="blahblah"
> unless="do-not-exec-target1"> ...
> </target>
>
> Can anyone help clear this up for me?
> Many thanks!
> - Tom
>
>
__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org