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 2003/11/17 17:24:51 UTC

DO NOT REPLY [Bug 24756] New: - support property values containing refs to undefined properties

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=24756>.
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=24756

support property values containing refs to undefined properties

           Summary: support property values containing refs to undefined
                    properties
           Product: Ant
           Version: 1.6Beta
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Core
        AssignedTo: dev@ant.apache.org
        ReportedBy: jmlennon@us.ibm.com


Once a property's value is set, it is never re-evaluated.
If the initial value contains a reference to another not-yet-defined
property, e.g.:

  <property name="foo.dir" value="${base.dir}/bar"/>
  ...
  <property name="base.dir" value="/usr/local"/>

the second property's value is never substituted into the first's.

This makes it difficult to implement non-trivial multi-project
"default property" mechanisms that support overriding of the
default property values.  Here is an example:

========= build.xml CUT HERE =================

<?xml version="1.0"?>

<project name="props-bug" default="show-bug">

  <macrodef name="set-default-props">
    <!-- Set default property values.  More typically might be done in
         a separate project file that gets imported by multiple
         different development projects. -->
    <sequential>
      <property name="base.dir" value="/usr/local"/>
      <property name="foo.dir"  value="${base.dir}/foo"/>
    </sequential>
  </macrodef>

  <target name="show-bug">

    <!-- Override the default value of "foo.dir" without having
         to provide definition for "base.dir".  This doesn't work
         because Ant doesn't re-evaluate "foo.dir"s value after
         it's initially set. -->  
    <property name="foo.dir" value="${base.dir}/bar"/>

    <set-default-props/>

    <echo message="Expected value: /usr/local/bar"/>
    <echo message="Actual value:   ${foo.dir}"/>
  </target>

</project>

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