Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Override ignored for property

Status
Not open for further replies.

markgargan

Programmer
Apr 4, 2005
25
IE
Hi folks,

Here's a very simple ant project.

<project name="test" default="testPrintPath" basedir=".">

<macrodef name="printPath">
<attribute name="path"/>
<sequential>
<pathconvert targetos="windows" property="pathString" refid="@{path}"/>
<echo message="The path @{path} is ${pathString}"/>
</sequential>
</macrodef>

<target name="testPrintPath">
<path id="aPath">
<pathelement location="c:\Z"/>
<pathelement location="c:\Y"/>
</path>

<printPath path="aPath"/>

<path id="anotherPath">
<pathelement location="c:\X"/>
<pathelement location="c:\W"/>
</path>

<printPath path="anotherPath"/>

</target>

</project>

It simply creates two paths, one is c:\Z;c:\Y and the other
is c:\X;c:\W

However, when I go to print these paths out, using my macrodef <b>printPath</b> the second path is always equal to the first path.

I've run this using verbose and I get the line

Override ignored for property pathString

Any one any ideas how do I avoid this from happening?

Thanks,
Mark.
 
I think properties in ant are immutable once set. They can't be treated like variables taking a variety of values over time.

Tim
---------------------------
"Your morbid fear of losing,
destroys the lives you're using." - Ozzy
 
Thanks Tim,

That makes sense. Think I've managed a work around
but it's just not so pretty.

Thanks,
Mark.
 
Fancy sharing your workaround so others could benefit?

Tim
---------------------------
"Your morbid fear of losing,
destroys the lives you're using." - Ozzy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top