ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Reeves, Paul C" <>
Subject RE: Rant on immutable properties
Date Mon, 02 Aug 2004 13:39:31 GMT
You can get around the immutable aspects of properties via the Ant-Contrib

Specifically, you may use <propertycopy> with the parameter override="true"
to re-assign a property.

This runs counter to the philosophy of ant, but I find it essential in my
work.  I tend to use it while iterating over a set of sub-tasks using
Ant-Contrib's <for> task.  I need to set arguments to pass to sub-tasks and
want to recycle the arguements as "variables" so that I only have to
maintain a single set of code that works for a whole set of projects.


P.S.  See

Here is an example of what I need to do.  I have a large set of projects
that need to be built via their own ant build files.  Each resides in a
unique directory and has a unique target that should be called.  These
settings are held in a property file.  The iteration looks like this:

    <!--Iterate over the custom ant build commands -->                      
    <for list       = "${proj.build_commands}" 
         delimiter  = ","
         param      = "string">

        <math result    = "build_cnt" 
              operand1  = "${build_cnt}" 
              operation = "+" 
              operand2  = "${incr}" 
              datatype  = "int"/>
        <propertycopy name     = "proj.ant_build.antfile"  
                      from     =
                      override = "true"
                      silent   = "true"/>
        <propertycopy name     = "proj.ant_build.dir"  
                      from     =
                      override = "true"
                      silent   = "true"/>
        <propertycopy name     = ""  
                      from     =
                      override = "true"
                      silent   = "true"/>
        <echo message="&#10;"/>
        <echo message="&#10;"/>
        <echo message="${} >>>Running:  ant -buildfile
'${proj.ant_build.antfile}' ${}&#10;"/>
        <trycatch property="proj.build_command.error">
            <!-- Call the custom ant build command -->
            <ant  antfile     = "${proj.ant_build.antfile}"
                  dir         = "${proj.ant_build.dir}"
                  target      = "${}"
                  inheritAll  = "false"
                  inheritRefs = "false"/>
            <ant antfile="build_log.xml" inheritAll="false"
              <property name="proj.build_success" value="false"/>
              <property name="proj.build_dir"
            <echo message="${} >>>ERROR:  Exception Thrown
in Ant Build (${})"/>
            <echo message="${} >>>        Exception:
            <throw message="${proj.build_command.error}&#10;&#10;&#10;***
ABORTING BUILD ***&#10;&#10;&#10;"/>

-----Original Message-----
From: Rhino []
Sent: Monday, August 02, 2004 6:53 AM
To: Ant Users List
Subject: Re: Rant on immutable properties

----- Original Message ----- 
From: "Martin Gainty" <>
To: <>
Sent: Friday, July 30, 2004 1:23 PM
Subject: Rant on immutable properties

> Hello All
> I have need to set the value of a property based on user input
> but cannot do so because properties are immutable?
> Is there a workaround?
Have you considered the 'input' core task? You could ask the user to supply
a value while the script executes and use the returned value in your script.


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

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

View raw message