bodewig 2002/06/11 01:14:16
Modified: . Tag: ANT_15_BRANCH WHATSNEW
docs/manual/OptionalTasks Tag: ANT_15_BRANCH jspc.html
src/etc/testcases/taskdefs Tag: ANT_15_BRANCH ant.xml
src/main/org/apache/tools/ant Tag: ANT_15_BRANCH
Project.java
src/main/org/apache/tools/ant/taskdefs Tag: ANT_15_BRANCH
Ant.java Property.java
src/testcases/org/apache/tools/ant/taskdefs Tag:
ANT_15_BRANCH AntTest.java
Log:
Enable <ant>'s nested <property> to override properties that have
previously been passed in via nested <property> but not properties
that have been specified on the command line.
See <http://marc.theaimsgroup.com/?t=102102515700002&r=1&w=2> for a
description that makes more sense 8-)
PR: 5662
Revision Changes Path
No revision
No revision
1.263.2.31 +16 -4 jakarta-ant/WHATSNEW
Index: WHATSNEW
===================================================================
RCS file: /home/cvs/jakarta-ant/WHATSNEW,v
retrieving revision 1.263.2.30
retrieving revision 1.263.2.31
diff -u -r1.263.2.30 -r1.263.2.31
--- WHATSNEW 5 Jun 2002 06:37:57 -0000 1.263.2.30
+++ WHATSNEW 11 Jun 2002 08:14:15 -0000 1.263.2.31
@@ -1,12 +1,24 @@
Changes from Ant 1.5 to current CVS 1.5 Branch
==============================================
+
Changes that could break older environments:
--------------------------------------------
-* Project.getBuildListeners now returns a clone of the listener list.
Changes to
- the returned list will not affect the listeners currently attached to the
- Project. It also means that it is safe to iterate over the returned list
- if listeners are added or removed during the traversal.
+* Project.getBuildListeners now returns a clone of the listener
+ list. Changes to the returned list will not affect the listeners
+ currently attached to the Project. It also means that it is safe to
+ iterate over the returned list if listeners are added or removed
+ during the traversal.
+
+Fixed bugs:
+-----------
+
+* <available> could fail to find files or directories that happen to
+ start with the name of the project's basedir but are not children of
+ the basedir.
+
+* Nested <property>'s inside <ant> can now be overriden by subsequent
+ <ant> and <antcall> tasks.
Changes from Ant 1.5beta1 to Ant 1.5beta2
=========================================
No revision
No revision
1.6.2.2 +1 -1 jakarta-ant/docs/manual/OptionalTasks/jspc.html
Index: jspc.html
===================================================================
RCS file: /home/cvs/jakarta-ant/docs/manual/OptionalTasks/jspc.html,v
retrieving revision 1.6.2.1
retrieving revision 1.6.2.2
diff -u -r1.6.2.1 -r1.6.2.2
--- jspc.html 6 Jun 2002 06:25:54 -0000 1.6.2.1
+++ jspc.html 11 Jun 2002 08:14:15 -0000 1.6.2.2
@@ -221,7 +221,7 @@
version 2.2 of the servlet specification is needed to compile or run the
java code.
<hr>
-<p align="center">Copyright © 2001 Apache Software Foundation. All
rights
+<p align="center">Copyright © 2001-2002 Apache Software Foundation. All
rights
Reserved.</p>
</body>
No revision
No revision
1.6.2.2 +46 -0 jakarta-ant/src/etc/testcases/taskdefs/ant.xml
Index: ant.xml
===================================================================
RCS file: /home/cvs/jakarta-ant/src/etc/testcases/taskdefs/ant.xml,v
retrieving revision 1.6.2.1
retrieving revision 1.6.2.2
diff -u -r1.6.2.1 -r1.6.2.2
--- ant.xml 10 May 2002 11:33:54 -0000 1.6.2.1
+++ ant.xml 11 Jun 2002 08:14:15 -0000 1.6.2.2
@@ -93,4 +93,50 @@
<property name="testprop" refid="inheritable" />
</ant>
</target>
+
+ <target name="test-property-override-inheritall-start">
+ <property name="test" value="1" />
+ <ant antfile="ant.xml"
+ target="test-property-override-inheritall-level-2"
+ inheritall="true">
+ <property name="test" value="2" />
+ </ant>
+ </target>
+
+ <target name="test-property-override-inheritall-level-2">
+ <property name="test" value="3" />
+ <ant antfile="ant.xml"
+ target="test-property-override-inheritall-level-3"
+ inheritall="true">
+ <property name="test" value="4" />
+ </ant>
+ </target>
+
+ <target name="test-property-override-inheritall-level-3">
+ <property name="test" value="5" />
+ <echo message="The value of test is ${test}" />
+ </target>
+
+ <target name="test-property-override-no-inheritall-start">
+ <property name="test" value="1" />
+ <ant antfile="ant.xml"
+ target="test-property-override-no-inheritall-level-2"
+ inheritall="false">
+ <property name="test" value="2" />
+ </ant>
+ </target>
+
+ <target name="test-property-override-no-inheritall-level-2">
+ <property name="test" value="3" />
+ <ant antfile="ant.xml"
+ target="test-property-override-no-inheritall-level-3"
+ inheritall="false">
+ <property name="test" value="4" />
+ </ant>
+ </target>
+
+ <target name="test-property-override-no-inheritall-level-3">
+ <property name="test" value="5" />
+ <echo message="The value of test is ${test}" />
+ </target>
</project>
No revision
No revision
1.108.2.6 +74 -2 jakarta-ant/src/main/org/apache/tools/ant/Project.java
Index: Project.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/Project.java,v
retrieving revision 1.108.2.5
retrieving revision 1.108.2.6
diff -u -r1.108.2.5 -r1.108.2.6
--- Project.java 6 Jun 2002 06:03:27 -0000 1.108.2.5
+++ Project.java 11 Jun 2002 08:14:15 -0000 1.108.2.6
@@ -160,6 +160,13 @@
* Mapping is String to String.
*/
private Hashtable userProperties = new Hashtable();
+ /**
+ * Map of inherited "user" properties - that are those "user"
+ * properties that have been created by tasks and not been set
+ * from the command line or a GUI tool.
+ * Mapping is String to String.
+ */
+ private Hashtable inheritedProperties = new Hashtable();
/** Map of references within the project (paths etc) (String to Object).
*/
private Hashtable references = new Hashtable();
@@ -470,6 +477,23 @@
}
/**
+ * Sets a user property, which cannot be overwritten by set/unset
+ * property calls. Any previous value is overwritten. Also marks
+ * these properties as properties that have not come from the
+ * command line.
+ *
+ * @param name The name of property to set.
+ * Must not be <code>null</code>.
+ * @param value The new value of the property.
+ * Must not be <code>null</code>.
+ * @see #setProperty(String,String)
+ */
+ public synchronized void setInheritedProperty(String name, String value)
{
+ inheritedProperties.put(name, value);
+ setUserProperty(name, value);
+ }
+
+ /**
* Sets a property unless it is already defined as a user property
* (in which case the method returns silently).
*
@@ -531,7 +555,7 @@
*/
public String getUserProperty(String name) {
if (name == null) {
- return null;
+ return null;
}
String property = (String) userProperties.get(name);
return property;
@@ -570,6 +594,54 @@
}
return propertiesCopy;
+ }
+
+ /**
+ * Copies all user properties that have been set on the command
+ * line or a GUI tool from this instance to the Project instance
+ * given as the argument.
+ *
+ * <p>To copy all "user" properties, you will also have to call
+ * [EMAIL PROTECTED] #copyInheritedProperties
copyInheritedProperties}.</p>
+ *
+ * @param other the project to copy the properties to. Must not be null.
+ *
+ * @since Ant 1.5
+ */
+ public void copyUserProperties(Project other) {
+ Enumeration e = userProperties.keys();
+ while (e.hasMoreElements()) {
+ Object arg = e.nextElement();
+ if (inheritedProperties.containsKey(arg)) {
+ continue;
+ }
+ Object value = userProperties.get(arg);
+ other.setUserProperty(arg.toString(), value.toString());
+ }
+ }
+
+ /**
+ * Copies all user properties that have not been set on the
+ * command line or a GUI tool from this instance to the Project
+ * instance given as the argument.
+ *
+ * <p>To copy all "user" properties, you will also have to call
+ * [EMAIL PROTECTED] #copyUserProperties copyUserProperties}.</p>
+ *
+ * @param other the project to copy the properties to. Must not be null.
+ *
+ * @since Ant 1.5
+ */
+ public void copyInheritedProperties(Project other) {
+ Enumeration e = inheritedProperties.keys();
+ while (e.hasMoreElements()) {
+ String arg = e.nextElement().toString();
+ if (other.getUserProperty(arg) != null) {
+ continue;
+ }
+ Object value = inheritedProperties.get(arg);
+ other.setInheritedProperty(arg, value.toString());
+ }
}
/**
No revision
No revision
1.56.2.4 +6 -10
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Ant.java
Index: Ant.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Ant.java,v
retrieving revision 1.56.2.3
retrieving revision 1.56.2.4
diff -u -r1.56.2.3 -r1.56.2.4
--- Ant.java 28 May 2002 13:53:13 -0000 1.56.2.3
+++ Ant.java 11 Jun 2002 08:14:15 -0000 1.56.2.4
@@ -255,14 +255,8 @@
newProject.addDataTypeDefinition(typeName, typeClass);
}
- // set user-defined
- Hashtable props = getProject().getUserProperties();
- e = props.keys();
- while (e.hasMoreElements()) {
- String arg = e.nextElement().toString();
- String value = props.get(arg).toString();
- newProject.setUserProperty(arg, value);
- }
+ // set user-defined properties
+ getProject().copyUserProperties(newProject);
if (!inheritAll) {
// set Java built-in properties separately,
@@ -272,7 +266,7 @@
} else {
// set all properties from calling project
- props = getProject().getProperties();
+ Hashtable props = getProject().getProperties();
e = props.keys();
while (e.hasMoreElements()) {
String arg = e.nextElement().toString();
@@ -282,9 +276,10 @@
}
String value = props.get(arg).toString();
+ // don't re-set user properties, avoid the warning message
if (newProject.getProperty(arg) == null){
// no user property
- newProject.setProperty(arg, value);
+ newProject.setNewProperty(arg, value);
}
}
}
@@ -400,6 +395,7 @@
p.setProject(newProject);
p.execute();
}
+ getProject().copyInheritedProperties(newProject);
}
/**
1.48.2.3 +1 -1
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Property.java
Index: Property.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Property.java,v
retrieving revision 1.48.2.2
retrieving revision 1.48.2.3
diff -u -r1.48.2.2 -r1.48.2.3
--- Property.java 10 May 2002 11:33:54 -0000 1.48.2.2
+++ Property.java 11 Jun 2002 08:14:15 -0000 1.48.2.3
@@ -373,7 +373,7 @@
protected void addProperty(String n, String v) {
if (userProperty) {
if (project.getUserProperty(n) == null) {
- project.setUserProperty(n, v);
+ project.setInheritedProperty(n, v);
} else {
log("Override ignored for " + n, Project.MSG_VERBOSE);
}
No revision
No revision
1.11.2.3 +23 -1
jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/AntTest.java
Index: AntTest.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/AntTest.java,v
retrieving revision 1.11.2.2
retrieving revision 1.11.2.3
diff -u -r1.11.2.2 -r1.11.2.3
--- AntTest.java 17 May 2002 10:36:17 -0000 1.11.2.2
+++ AntTest.java 11 Jun 2002 08:14:16 -0000 1.11.2.3
@@ -269,6 +269,28 @@
project.removeBuildListener(pc);
}
+ public void testUserPropertyWinsInheritAll() {
+ getProject().setUserProperty("test", "7");
+ expectLogContaining("test-property-override-inheritall-start",
+ "The value of test is 7");
+ }
+
+ public void testUserPropertyWinsNoInheritAll() {
+ getProject().setUserProperty("test", "7");
+ expectLogContaining("test-property-override-no-inheritall-start",
+ "The value of test is 7");
+ }
+
+ public void testOverrideWinsInheritAll() {
+ expectLogContaining("test-property-override-inheritall-start",
+ "The value of test is 4");
+ }
+
+ public void testOverrideWinsNoInheritAll() {
+ expectLogContaining("test-property-override-no-inheritall-start",
+ "The value of test is 4");
+ }
+
private class BasedirChecker implements BuildListener {
private String[] expectedBasedirs;
private int calls = 0;
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>