You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bu...@apache.org on 2010/02/26 18:39:25 UTC

DO NOT REPLY [Bug 48825] New: Project.setProperty(String,String) no longer overrides an existing definition

https://issues.apache.org/bugzilla/show_bug.cgi?id=48825

           Summary: Project.setProperty(String,String) no longer overrides
                    an existing definition
           Product: Ant
           Version: 1.8.0
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: regression
          Priority: P2
         Component: Core
        AssignedTo: notifications@ant.apache.org
        ReportedBy: jglick@netbeans.org


Probably this method should be deprecated and its usages in XMLProperty and the
P4 tasks cleaned up, but in 1.8.0 it still exists and claims that

"Any existing property of the same name is overwritten, unless it is a user
property."

This does not seem to be true:

<project basedir="." default="x">
  <target name="x">
    <echo file="Override.java">
      public class Override extends org.apache.tools.ant.taskdefs.Property {
        protected void addProperty(String n, String v) {
          getProject().setProperty(n, v);
        }
      }
    </echo>
    <javac includeantruntime="true" srcdir="." destdir="."
includes="Override.java"/>
    <taskdef name="override" classname="Override" classpath="."/>
    <property name="p" value="1"/>
    <override name="p" value="2"/>
    <echo>${p}</echo>
  </target>
</project>

prints 2 (as expected) in Ant 1.7.1, but 1 in Ant 1.8.0.

I did not see anything in WHATSNEW about this either.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 48825] Project.setProperty(String,String) no longer overrides an existing definition

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48825

Jesse Glick <jg...@netbeans.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WONTFIX

--- Comment #4 from Jesse Glick <jg...@netbeans.org> 2010-02-27 16:14:47 UTC ---
(In reply to comment #3)
> So the problem is not that that Project#setProperty does not override
> properties any more, rather that Property#addProperty is not called in your
> piece of code.

Indeed. A kind of incompatibility in Property but probably not one that can be
trivially fixed. (A demonstration of why you should not permit subclassing
without a lot of preparation...)

An alternate version of the task that works in both 1.7.1 and 1.8.0:

public class OverrideTask extends Property {
  protected @Override void addProperty(String n, String v) {
    getProject().setProperty(n, v);
  }
  protected /*@Override*/ void addProperty(String n, Object v) {
    getProject().setProperty(n, (String) v);
  }
}

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 48825] Project.setProperty(String,String) no longer overrides an existing definition

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48825

--- Comment #2 from Antoine Levy-Lambert <an...@apache.org> 2010-02-26 22:24:43 UTC ---
I just tried this against the head revision of ant in trunk and the problem is
there too.

--Antoine

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 48825] Project.setProperty(String,String) no longer overrides an existing definition

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48825

--- Comment #3 from Antoine Levy-Lambert <an...@apache.org> 2010-02-26 22:31:45 UTC ---
Hello Jesse,

I have rewritten your project file in this way :

<project basedir="." default="x">
  <target name="x">
    <echo file="Override.java">
      public class Override extends org.apache.tools.ant.Task {
        private String n;
        private String v;
        public void setName(String n) {
          this.n = n;
        }
        public void setValue(String v) {
          this.v = v;
        }
        public void execute() {
          getProject().setProperty(n, v);
        }
      }
    </echo>
    <javac includeantruntime="true" srcdir="." destdir="."
includes="Override.java"/>
    <taskdef name="override" classname="Override" classpath="."/>
    <property name="p" value="1"/>
    <override name="p" value="2"/>
    <echo>${p}</echo>
  </target>
</project>


This time the output is 2.

So the problem is not that that Project#setProperty does not override
properties any more, rather that Property#addProperty is not called in your
piece of code.

Regards,

Antoine

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 48825] Project.setProperty(String,String) no longer overrides an existing definition

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48825

Jesse Glick <jg...@netbeans.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jglick@netbeans.org

--- Comment #1 from Jesse Glick <jg...@netbeans.org> 2010-02-26 17:40:11 UTC ---
Reference: http://netbeans.org/bugzilla/show_bug.cgi?id=181284

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.