Holger Rauch - 2007-10-31

Hi to all ant-contrib forum members,

I'm currently struggling with the problem of how to access nested var values.
More precisely, I'm talking about my try to use something like @{@{othervar}} to do so, which is not quite right (see also XML comment in the Ant build file below).

Any help is greatly appreciated. Thanks in advance for any help/links, etc. :-)))

Kind regards,



<?xml version="1.0" encoding="iso-8859-1" ?>

<project name="nestedvartest" default="do" basedir=".">

  <taskdef resource="net/sf/antcontrib/antcontrib.properties"/>

  <macrodef name="varnamevalinmac">
    <attribute name="samplevar" default="NOT SET" />
    <attribute name="othervar" default="NOT SET" />
      <var name="@{samplevar}" unset="true" />
      <echo message="before for loop: othervar contains @{othervar}" />
      <for list="a,b,c,d,e"
      <var name="@{othervar}" value="@{othervarval}" />
      <echo message="inside for loop: @{othervar} contains @{othervarval}" />
          <isset property="@{samplevar}" />
          <!-- What's the right syntax for accessing @{othervar}'s value after it has been assigned, I mean *without* using the for loop param's value??? -->
          <var name="@{samplevar}" value="@{@{othervar}}" />
          <echo message="@{samplevar} previously NOT set; initially contains ${@{samplevar}}" />
          <var name="@{samplevar}" value="${@{samplevar}} @{@{othervar}}" />
      <!-- Analogous for @{samplevar}'s value -->
      <echo message="@{samplevar} contains @{@{samplevar}}" />

  <target name="do">
    <varnamevalinmac samplevar="test"
             othervar="test2" />