ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter Reilly" <peter.kitt.rei...@gmail.com>
Subject Re: Getting around Set Property Values
Date Fri, 31 Aug 2007 17:41:28 GMT
Currently you need to:

1 ) use <ac:var unset="yes" name="destdir"/>
2) use the invent new property based on macro instance trick:

         <property name="@{module}-destdir"
             value="${workdir}/WEB-INF/classes/com/solbright/@{param1}/servlet"/>

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

for ant 1.8.0, we are considering implementing a "local" property:

         <local name="destdir"/> <!-- makes a local property called
"destdir" -->
         <property name="destdir"
             value="${workdir}/WEB-INF/classes/com/solbright/@{param1}/servlet"/>

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

Peter

On 8/31/07, David Weintraub <qazwart@gmail.com> wrote:
> Okay,
>
> 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"/>
>     <sequential>
>         <property name="destdir"
>             value="${workdir}/WEB-INF/classes/com/solbright/@{param1}/servlet"/>
>
>         <mkdir dir="${destdir}"/>
>         <javac srcdir="@{module}"
>             destdir="${destdir}"/>
>     </sequential>
> <macrodef>
>
> 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
> called?
>
> --
> David Weintraub
> qazwart@gmail.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message