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 26128] - Nested ant invocations can override properties
Date Wed, 14 Jan 2004 16:37:36 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=26128>.
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=26128

Nested ant invocations can override properties





------- Additional Comments From peter.reilly@corvil.com  2004-01-14 16:37 -------
The doc is a little vague for "inherited" properties.
The easiest way to solve the problem is to
write a custom task to set userproperties:

    package task;
    import org.apache.tools.ant.taskdefs.Property;
    public class UserProperty extends Property {
       public UserProperty() {
          super(true); // set this as a user property
       }
       // Property#addProperty is incorrect for user properties
       public void addProperty(String n, String v) {
          if (getProject().getUserProperty(n) == null) {
             getProject().setUserProperty(n, v);
          } else {
             log("Override ignored for " + n, Project.MSG_VERBOSE);
          }
       }
    }

<project name="1" basedir="." default="test">
  <taskdef name="userproperty" classname="task.UserProperty"/>
  <userproperty name="test.property" value="1"/>
  <target name="test" description="level 1">
    <ant antfile="2.xml" dir="." inheritall="true"/>
  </target>
</project>

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


Mime
View raw message