ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Burgess, Benjamin" <>
Subject RE: Getting around Set Property Values
Date Fri, 31 Aug 2007 17:38:48 GMT
You could use the parameter being passed in as part of the name of your
property.  Something like:

<?xml version="1.0"?>
<project name="test" default="test" basedir=".">
	<macrodef name="test">
	    <attribute name="module"/>
	        <property name="@{module}destdir"
	        <mkdir dir="${@{module}destdir}"/>
	<target name="test">
		<test module="test1"/>
		<test module="test2"/>
		<test module="test3"/>

Ben Burgess

-----Original Message-----
From: David Weintraub [] 
Sent: Friday, August 31, 2007 1:14 PM
To: Ant Users List
Subject: Getting around Set Property Values


I've got a quick question. Once a property is set, it can never be
overridden. (Actually, you can use the AntContrib task 'variable' to
do this, but...)

I am defining a Maco that looks like this:

<macrodef name="compile">
    <attribute name="module"/>
        <property name="destdir"

        <mkdir dir="${destdir}"/>
        <javac srcdir="@{module}"

When I call the Macro the first time, the property "destdir" will be
set to the correct value, and everything will be fine.

However, on the second call, the property "destdir" won't be reset
since you cannot change the value of a property once it is set. The
files will be built in the wrong place.

How can I get around this issue? I could simply put my destination
directory in every place, but that means if I change something, I have
to hunt down all the places where it was set, and change it there. Is
there a way I can have the property be unset after the macro is

David Weintraub

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

This message, including any attachments, contains confidential information intended 
for a specific individual and purpose, and is protected by law. If you are not the intended

recipient, please contact the sender immediately by reply e-mail and destroy all copies.
You are hereby notified that any disclosure, copying, or distribution of this message, or
the taking of any action based on it, is strictly prohibited.


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

View raw message