You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bu...@apache.org on 2004/08/12 17:33:56 UTC

DO NOT REPLY [Bug 30619] New: - References created within a macro have local scope

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=30619>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=30619

References created within a macro have local scope

           Summary: References created within a macro have local scope
           Product: Ant
           Version: 1.6.2
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: Major
          Priority: Other
         Component: Core tasks
        AssignedTo: dev@ant.apache.org
        ReportedBy: dylan@van-iersel.org


I have a <macrodef/> to easily create fileset- and path-references so that they 
can be used all over my project in various buildfiles.

However, a reference created by/in such a macro, is lost as soon as the 
buildprocess leaves the context of the calling target:

  <macrodef name="create-refs">
    <attribute name="filelist"/>
    <attribute name="reference"/>
    <sequential>
      <path id="@{reference}.path">
        <fileset dir="${lib.dir}" includes="@{filelist}" id="@{reference}.fs"/>
      </path>
      <echo level="info" message="Created references '@{reference}.path' and 
'@{reference}.fs'."/>
    </sequential>
  </macrodef>

Calling this macro and displaying its contents within the same target is ok:

  <target name="create-references">
    <create-refs filelist="${test.filelist}" reference="test"/>
    <echorefs refid="test.path"/>
  </target>

yields:

create-references:
     [echo] Created references: 'test.fs' and 'test.path'.
     [echo] Reference test.fs consists of sample.jar from C:\projects\sample\lib 

However, trying to display its content from the parent target gives an error 
(note that 'init' is dependent on 'create-references'):

init:

create-references:
     [echo] Created references: 'test.fs' and 'test.path'.
     [echo] Reference test.fs consists of sample.jar from C:\projects\sample\lib 

BUILD FAILED
C:\projects\sample\dependencies.xml:198: The following error occurred while 
executing this line:
C:\projects\sample\dependencies.xml:23: Reference test.fs not found.

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