holtdl 2002/06/27 11:35:49
Modified: . Tag: ANT_15_BRANCH WHATSNEW
docs/manual/CoreTasks Tag: ANT_15_BRANCH pathconvert.html
src/main/org/apache/tools/ant/taskdefs Tag: ANT_15_BRANCH
PathConvert.java
Log:
Make Eugene happy :) Add new 'setonempty' attr to say whether to
set the property, even if the result is the empty string.
Revision Changes Path
No revision
No revision
1.263.2.53 +7 -0 jakarta-ant/WHATSNEW
Index: WHATSNEW
===================================================================
RCS file: /home/cvs/jakarta-ant/WHATSNEW,v
retrieving revision 1.263.2.52
retrieving revision 1.263.2.53
diff -u -r1.263.2.52 -r1.263.2.53
--- WHATSNEW 27 Jun 2002 07:51:55 -0000 1.263.2.52
+++ WHATSNEW 27 Jun 2002 18:35:48 -0000 1.263.2.53
@@ -7,6 +7,11 @@
* <zip> and friends would always update existing archive if you set
the update attribute to true.
+* To support backward compatibility with older versions, <pathconvert>
+ will once again set the property, even if the result is the empty
+ string, unless the new 'setonempty' attribute is set to false|no|off
+ (default is "true").
+
Changes from Ant 1.5beta2 to Ant 1.5beta3
=========================================
@@ -25,6 +30,8 @@
* Some messages that are printed during startup will not be
written to the logfile specified via -logfile as they might destroy
the format of the file for special BuildLoggers (like XmlLogger).
+
+* <pathconvert> won't set the property if the result is the empty string.
Fixed bugs:
-----------
No revision
No revision
1.9.2.1 +5 -0 jakarta-ant/docs/manual/CoreTasks/pathconvert.html
Index: pathconvert.html
===================================================================
RCS file: /home/cvs/jakarta-ant/docs/manual/CoreTasks/pathconvert.html,v
retrieving revision 1.9
retrieving revision 1.9.2.1
diff -u -r1.9 -r1.9.2.1
--- pathconvert.html 25 Apr 2002 06:14:59 -0000 1.9
+++ pathconvert.html 27 Jun 2002 18:35:48 -0000 1.9.2.1
@@ -72,6 +72,11 @@
<td valign="top" align="center">No; if omitted, a nested
<code><path></code> element must be supplied.</td>
</tr>
+ <td valign="top">setonempty</td>
+ <td valign="top">Should the property be set, even if the result
+ is the empty string?
+ <td valign="top" align="center">No; default is "true".
+ </tr>
</table>
<h3>Parameters specified as nested elements</h3>
<h4>map</h4>
No revision
No revision
1.18.2.4 +29 -7
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/PathConvert.java
Index: PathConvert.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/PathConvert.java,v
retrieving revision 1.18.2.3
retrieving revision 1.18.2.4
diff -u -r1.18.2.3 -r1.18.2.4
--- PathConvert.java 24 Jun 2002 02:28:08 -0000 1.18.2.3
+++ PathConvert.java 27 Jun 2002 18:35:49 -0000 1.18.2.4
@@ -101,6 +101,10 @@
*/
private boolean onWindows = false;
/**
+ * Set if we should create a new property even if the result is empty
+ */
+ private boolean setonempty = true;
+ /**
* The property to receive the conversion
*/
private String property = null;//
@@ -268,6 +272,17 @@
targetWindows = !targetOS.equals("unix");
}
+ /**
+ * Set setonempty
+ *
+ * If false, don't set the new property if the result is the empty
string.
+ * @param setonempty true or false
+ *
+ * @since Ant 1.5
+ */
+ public void setSetonempty(boolean setonempty) {
+ this.setonempty = setonempty;
+ }
/**
* The property into which the converted path will be placed.
@@ -401,13 +416,20 @@
}
}
- // Place the result into the specified property
- if( rslt.length() > 0 ) {
- String value = rslt.toString();
- log("Set property " + property + " = " + value,
- Project.MSG_VERBOSE);
- getProject().setNewProperty(property, value);
- }
+ // Place the result into the specified property,
+ // unless setonempty == false
+ String value = rslt.toString();
+ if(setonempty) {
+ log("Set property " + property + " = " + value,
+ Project.MSG_VERBOSE);
+ getProject().setNewProperty(property, value);
+ } else {
+ if(rslt.length() > 0) {
+ log("Set property " + property + " = " + value,
+ Project.MSG_VERBOSE);
+ getProject().setNewProperty(property, value);
+ }
+ }
} finally {
path = savedPath;
dirSep = savedDirSep;
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>