From bd3509fb89c171ee9f9631fe241c1ea7c1edf46a Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Fri, 7 Dec 2001 07:16:56 +0000 Subject: [PATCH] Don't punish people who want to modify the values of existing properties in tasks of their own. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270084 13f79535-47bb-0310-9956-ffa450edef68 --- WHATSNEW | 8 ++++---- src/main/org/apache/tools/ant/Project.java | 14 ++++---------- .../org/apache/tools/ant/taskdefs/Available.java | 7 +++++++ 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/WHATSNEW b/WHATSNEW index 4cfa6cf07..81d4c0132 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -16,10 +16,10 @@ Changes that could break older environments: represents a directory. Support for nested filesets is provided instead. -* Some loopholes in the immutability rule have been closed. It is no longer - possible to overwrite a property using tasks like , , - , , or . In some exceptional cases it will - generate a warning if you attempt to subvert property immutability. +* It is no longer possible to overwrite a property using tasks like + , , , or . In some exceptional + cases it will generate a warning if you attempt to overwrite an + existing property. * Taskwriters please note: Whenever tasks had any overloaded set* methods, Ant's introspection mechanism would select the last overloaded method diff --git a/src/main/org/apache/tools/ant/Project.java b/src/main/org/apache/tools/ant/Project.java index 9b7ad16ff..6f1e8b300 100644 --- a/src/main/org/apache/tools/ant/Project.java +++ b/src/main/org/apache/tools/ant/Project.java @@ -298,10 +298,8 @@ public class Project { /** * set a property. Any existing property of the same name * is overwritten, unless it is a user property. - * the immutability policy is not implemented at this level * @param name name of property * @param value new value of the property - * @deprecated use, set setNewProperty */ public void setProperty(String name, String value) { // command line properties take precedence @@ -311,10 +309,8 @@ public class Project { } if (null != properties.get(name)) { - log("DEPRECATED - Project.setProperty('" + name + "','" + value + "') used " + - "to overide an immutable property. Task writer should use Project.setNewProperty() " + - "instead and the build writer should not reuse the same property name for " + - "different values."); + log("Overriding previous definition of property " + name, + MSG_VERBOSE); } log("Setting project property: " + name + " -> " + @@ -323,15 +319,13 @@ public class Project { } /** - * set a property. Any existing property of the same name - * is overwritten, unless it is a user property. - * the immutability policy is enforced at this level + * set a property. An existing property of the same name + * will not be overwritten. * @param name name of property * @param value new value of the property * @since 1.5 */ public void setNewProperty(String name, String value) { - // command line properties take precedence if (null != properties.get(name)) { log("Override ignored for property " + name, MSG_VERBOSE); return; diff --git a/src/main/org/apache/tools/ant/taskdefs/Available.java b/src/main/org/apache/tools/ant/taskdefs/Available.java index 01f098ca5..0cd62dd47 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Available.java +++ b/src/main/org/apache/tools/ant/taskdefs/Available.java @@ -156,6 +156,13 @@ public class Available extends Task implements Condition { } if (eval()) { + String lSep = System.getProperty("line.separator"); + if (null != project.getProperty(property)) { + log("DEPRECATED - used to overide an existing property. " + + lSep + + " Build writer should not reuse the same property name for " + + lSep + "different values."); + } this.project.setProperty(property, value); } }