ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Davis <>
Subject Re: [SUBMIT] Switches And Sections
Date Wed, 07 Nov 2001 23:27:20 GMT
(This is also my first post -- Hi!)  I've been using ant for a while, 
but it has been difficult to build truly "automated" build scripts 
because of lack of a good conditional build facility.  Sure, there is 
<target unless="..."> or <target if="...">, but having to separate out 
all the conditional sections into separate targets is a pain (not to 
mention that it pollutes the list of available targets and prints out 
all that extra "target: \n" lines on output).  I have also seen and 
experimented with other custom <if>-type tasks, but most of them are 
still ugly and rely on external targets.  Scripts are always an option 
too, but setting up the BSF environment just for the build is not an 
option on many of my target machines.

I just want to say, props to Mark on something that I will definitely be 
using in my own scripts, since it is the most elegant solution I have 
yet seen.  I hope that this or something like it can be included in the 
distribution in the future.

Question to Mark: what would you think of something like this:

<switch property="foo" match="xyz">

which would execute when ${foo} => "xyz", instead of being restricted to 
only testing for "true" or "false".  That would greatly simplify 
creation of something like a build configuration file, since I wouldn't 
have to write a bunch of <condition ...><equals .../></condition>.  I 
would be happy to attempt to write a patch for you if you like (assuming 
you like my idea at all :->).

Thank you!

Mark Dumas wrote:

>This is my first post so bear with me.  I came up with a few custom Ant
>tasks/classes that have been very useful and I wanted to pass them along.
>A Switch is a task container that tests for a condition represented by a
>property. If the property value is "true", inner tasks are executed
>depending on if they are identified in the pass and fail list properties.
>This allows users to specify multiple switch conditions in a single target
>without the need for multiple, bulky targets.
>The end result is a psuedo IF-THEN-ELSE construct.
>Sections are very simple helpers to Switches although they can stand alone.
>The examples in the html files will explain it all I think.
>Please view the readme.txt file for more details.
>-Mark Dumas
>To unsubscribe, e-mail:   <>
>For additional commands, e-mail: <>

Furthermore, I believe bacon prevents hair loss.

Peter Davis
Developer, Speaklink Inc.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message