ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rhino <>
Subject Basic question re Antform and conditional execution of tasks
Date Wed, 24 Feb 2010 23:41:15 GMT
I was reasonably comfortable with Ant a few years ago but haven't 
touched it in quite a while so I need a bit of a refresher. I've tried 
looking in the manua but it always seems to answer only part of the 
question so I thought I'd try here.

Among the things that my Ant script needs to do is write a specific 
document. That document has three optional parts, each of which the 
person running the script may choose to write or omit. I'm leaning 
toward using an Ant form with a checkSelectionProperty for each of the 
three optional parts.

The relevant bit of my script is:

<!--   Let the user choose to show or hide specific items. -->
<target name="verify_switches" description="Let the user choose which 
content to omit.">
    <antform title="Choose Information Which Will Not Be Displayed">
        <label>Use the checkboxes to control which of the following 
content is shown. Choose Abort to cancel the build.</label>
        <checkSelectionProperty label="" property="omit.optional.part1" 
values="Omit Optional Part 1"/>
        <checkSelectionProperty label="" property="omit.optional.part2" 
values="Omit Optional Part 2"/>
        <checkSelectionProperty label="" property="omit.optional.part3" 
values="Omit Optional Part 3"/>
            <button label="Abort" target="abort2" type="cancel"/>
            <button label="Ok" type="ok"/>

<target name="Omit_Optional_Part1" description="Omit optional part 1." 
    <replaceregexp file="${baz.src}\${baz.pkg}\"
        match="^[\s]*public static final boolean 
        replace="    public static final boolean SHOW_OPTIONAL_PART1 = 
<target name="Omit_Optional_Part2" description="Omit optional part 2." 
    <replaceregexp file="${baz.src}\${baz.pkg}\"
        match="^[\s]*public static final boolean 
        replace="    public static final boolean SHOW_OPTIONAL_PART2 = 
<target name="Omit_Optional_Part3" description="Omit optional part 3." 
    <replaceregexp file="${baz.src}\${baz.pkg}\"
        match="^[\s]*public static final boolean 
        replace="    public static final boolean SHOW_OPTIONAL_PART3 = 
<target name="abort2" description="Display a message that the build was 
    <fail message="The user chose not to proceed with the build."/>


The "verify_switches" target is part of the "depends" on my 'buildall' 

What I'm TRYING to do is get the form to display three separate 
checkboxes. Each checkbox identifies a different one of the three 
optional parts of the document. The user puts a checkmark beside each of 
the optional parts that he wants to OMIT in the document; if he doesn't 
put a checkmark beside a given part, that part will be written in the 
document. For each checkbox that is checked, a new property is created

Then, the other three targets, Omit_Optional_Part1, Omit_Optional_Part2, 
and Omit_Optional_Part3 are supposed to be invoked but ONLY if the 
relevant checkbox was checked on the AntForm. The three "omit" targets 
simply edit a class containing constants and change the value of one 
boolean each from true, the default, to false. In other words, if the 
user chooses to omit part 1 from the document, the "Omit_Optional_Part1" 
target changes a constant named SHOW_OPTIONAL_PART1 from true to false. 
And so on for the other two "optional" targets.

Unfortunately, this code doesn't work. While the AntForm displays just 
fine, it doesn't seem to be creating the relevant properties. Or maybe 
it is and the "optional" targets just aren't coded correctly. The fact 
is that the the "optional" targets sometimes run regardless of the 
existence of the properties created in the form and sometimes DON'T run, 
even if the property should have been created.

Obviously, I'm doing something wrong but I can't figure it out from the 
documentation I've been able to find. AntForm is especially poorly 
documented in that it has very few examples and none that illustrate how 
to work with checkSelectionProperty.

Can someone kindly tell me what I'm doing wrong?

I am running Ant 1.7.1 in Eclipse 3.5.1 (Galileo). My OS is Windows XP SP2.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message