ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Frank E. Weiss" <>
Subject Re: suggestions
Date Wed, 26 Sep 2001 05:47:52 GMT
The reason ant is so intriguing (to me) is because sometimes it almost seems to
be wanting to be prolog. This is not such a stretch. Consider if/unless to be
guarded clauses, or targets. Consider the depends mechanism a form of functional
programming, whereby a computation is done inside-out. Is lazy evaluation in
there somewhere, too?

But seriously, this leads to another idea, conditional depends. For  example
(with a change of depends from an attribute of the target to a child of the
target, which is actually better XML, IMHO):

<target name="mytarget">
    <depends target="do-if-foo" if="${my-var-is-foo}"/>
    <depends target="do-if-bar" if="${my-var-is-bar}"/>

For those wanting to criticize this form as not providing an ordering for
depends, I offer that XML has a concept of document order of nodes.

This also allows for using an if construct when building the dependencies,
thereby being able to prune a whole subtree of dependant targets.

I'd also ask the developers to consider real if expressions. Can't ant leverage
the XPath expression parser from Xalan?

P.S. Currently, the depends attribute always implies an AND. For example:

<target name="foo" depends="bar,mung"/>

means foo depends on bar AND mung. It seems like many users are also looking for
an OR form of depends. Like: "foo depends on (bar if property do-bar) OR (mung
if property do-mung)".

Mike Roberts wrote:

> Just come across this if-evaluation problem today. A complete hack I came up
> with is:
>     <target name="hack_preparer" if="myvar">
>         <delete dir="touchdir"/>
>         <mkdir dir="touchdir"/>
>         <touch file="touchdir/${myvar}"/>
>         <available file="touchdir/foo" property="my_var_is_foo"/>
>         <available file="touchdir/bar" property="my_var_is_bar"/>
>         <delete dir="touchdir"/>
>     </target>
>     <target name="do_if_foo" if="my_var_is_foo">
>     </target>
>     <target name="do_if_bar" if="my_var_is_bar">
>     </target>
>     <target name="mytarget" depends="hack_preparer">
>         <antcall target="do_if_foo"/>
>         <antcall target="do_if_bar"/>
>     </target>
> I know that the ant philosophy is that I should use a different property for
> different scenarios. What I actually what conditional
> evaluation for is that I want to check for special cases of a property, and
> otherwise use the property value itself (so, a variant of the above hack)
> eg:
> - 'build trunk' will build from the single trunk location
> - 'build 1.3' will build branch number 1.3
> The only clean solution I can find, while keeping the user skill down, is to
> do more stuff in my ant wrapper script. I don't like this
> though since I'd rather keep all my ant wrapper scripts the same.
> Mike

View raw message