Browse Source

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
master
Stefan Bodewig 23 years ago
parent
commit
bd3509fb89
3 changed files with 15 additions and 14 deletions
  1. +4
    -4
      WHATSNEW
  2. +4
    -10
      src/main/org/apache/tools/ant/Project.java
  3. +7
    -0
      src/main/org/apache/tools/ant/taskdefs/Available.java

+ 4
- 4
WHATSNEW View File

@@ -16,10 +16,10 @@ Changes that could break older environments:
represents a directory. Support for nested filesets is provided represents a directory. Support for nested filesets is provided
instead. instead.


* Some loopholes in the immutability rule have been closed. It is no longer
possible to overwrite a property using tasks like <checksum>, <condition>,
<exec>, <pathconvert>, or <tstamp>. 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
<condition>, <exec>, <pathconvert>, or <tstamp>. 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, * Taskwriters please note: Whenever tasks had any overloaded set* methods,
Ant's introspection mechanism would select the last overloaded method Ant's introspection mechanism would select the last overloaded method


+ 4
- 10
src/main/org/apache/tools/ant/Project.java View File

@@ -298,10 +298,8 @@ public class Project {
/** /**
* set a property. Any existing property of the same name * set a property. Any existing property of the same name
* is overwritten, unless it is a user property. * is overwritten, unless it is a user property.
* <i>the immutability policy is not implemented at this level</i>
* @param name name of property * @param name name of property
* @param value new value of the property * @param value new value of the property
* @deprecated use, set setNewProperty
*/ */
public void setProperty(String name, String value) { public void setProperty(String name, String value) {
// command line properties take precedence // command line properties take precedence
@@ -311,10 +309,8 @@ public class Project {
} }


if (null != properties.get(name)) { 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 + " -> " + 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.
* <i>the immutability policy <b>is</b> enforced at this level</i>
* set a property. An existing property of the same name
* will not be overwritten.
* @param name name of property * @param name name of property
* @param value new value of the property * @param value new value of the property
* @since 1.5 * @since 1.5
*/ */
public void setNewProperty(String name, String value) { public void setNewProperty(String name, String value) {
// command line properties take precedence
if (null != properties.get(name)) { if (null != properties.get(name)) {
log("Override ignored for property " + name, MSG_VERBOSE); log("Override ignored for property " + name, MSG_VERBOSE);
return; return;


+ 7
- 0
src/main/org/apache/tools/ant/taskdefs/Available.java View File

@@ -156,6 +156,13 @@ public class Available extends Task implements Condition {
} }


if (eval()) { if (eval()) {
String lSep = System.getProperty("line.separator");
if (null != project.getProperty(property)) {
log("DEPRECATED - <available> 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); this.project.setProperty(property, value);
} }
} }


Loading…
Cancel
Save