ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 21724] - references are not passed by antcall
Date Tue, 22 Jul 2003 12:21:30 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21724>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21724

references are not passed by antcall

peter.reilly@corvil.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|1.6                         |---



------- Additional Comments From peter.reilly@corvil.com  2003-07-22 12:21 -------
(Long message following::)
(Note: I was writing this while antonie was fixing the problem)

The problem here is the id attribute and handling of references.
This is a special attribute that gets inserted at parse-time
and procesed and also inserted at run-time, 
The original idea (I think) was to emulate the id in html, in
that one can refer to a task in the build script without it having
run. This is used in <script>'s to refer to tasks in other targets.
(see the example in current cvs)
  <target name="sub">
    <echo id="theEcho"/>
  </target>

  <target name="sub1">
    <script language="netrexx"><![CDATA[
      theEcho.setMessage("In sub1")
      sub.execute
    ]]></script>
  </target>

This is ok for tasks, but does not work too well for
datatypes as Project#AntRefTable#get() gets a
UnknownElement and then tries to get a task from
it after calling maybeconfigure. This returns
null as the filterset is not a task. Normally
this is not a problem as maybeconfigure on the
filterset will cause the "foo" id to be
replaced by the filterset.

For antcall this does not work as in the sub project,
the foo is an id found during the parse stage, and so
in Ant#addReferences(), it will be in the newProject.getReferences()
hashmap and the check:
                newReferences.containsKey(key)
will be true, thus the foo reference from the calling project
will not be copied to the sub project.

Antonie's fix will solve the problem with the unit test but will
not solve the general problem.

For example:
<project name="test" default="copytest" basedir=".">

  <target name="copytest2">
    <copy file="copytest.in" toFile="copytest1.out" overwrite="true">
      <filterset refid="foo"/>
    </copy>
    <concat><path path="copytest1.out"/></concat>
  </target>

  <target name="copytest">
    <echo file="copytest.in">@@foo@@</echo>
    <filterset id="foo" begintoken="@@" endtoken="@@">
      <filter token="foo" value="bar"/>
    </filterset>
    <antcall target="copytest2" inheritrefs="true"/>
    <copy file="copytest.in" toFile="copytest2.out" overwrite="true">
      <filterset refid="foo"/>
    </copy>
    <concat><path path="copytest2.out"/></concat>
  </target>

  <target name="copytest2">
    <copy file="copytest.in" toFile="copytest2.out" overwrite="true">
      <filterset refid="foo"/>
    </copy>
  </target>

  <target name="copytest3">
    <echo file="copytest.in">@@foo@@</echo>
    <filterset id="foo" begintoken="@@" endtoken="@@">
      <filter token="foo" value="notbar"/>
    </filterset>
    <copy file="copytest.in" toFile="copytest3.out" overwrite="true">
      <filterset refid="foo"/>
    </copy>
    <concat><path path="copytest3.out"/></concat>
  </target>

</project>

Generates:
copytest:

copytest2:
     [copy] Copying 1 file to /home/preilly/proj/learning/ref
   [concat] notbar


     [copy] Copying 1 file to /home/preilly/proj/learning/ref
   [concat] bar

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


Mime
View raw message