diff --git a/WHATSNEW b/WHATSNEW index 61d7401ff..0cab81c73 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -611,6 +611,11 @@ Other changes: timestamp even if the file is modified. Bugzilla Report 39002. + * The child-elements and have + a new attribute that controls whether properties in nested text get + expanded. + Bugzilla Report 11585. + Changes from Ant 1.7.0 TO Ant 1.7.1 ============================================= diff --git a/docs/manual/CoreTasks/replace.html b/docs/manual/CoreTasks/replace.html index 00715c746..949112b05 100644 --- a/docs/manual/CoreTasks/replace.html +++ b/docs/manual/CoreTasks/replace.html @@ -123,7 +123,7 @@ have been regenerated by this task.

preserveLastModified Keep the file timestamp(s) even if the file(s) - is(are) modified. + is(are) modified. since Ant 1.8.0. No, defaults to false @@ -139,9 +139,24 @@ nested <include>, <exclude> and

Since Ant 1.8.0 this task supports any filesystem based resource collections as nested elements.

+

replacetoken and replacevalue

If either the text you want to replace or the replacement text cross line boundaries, you can use nested elements to specify them.

+

The elements support attributes:

+ + + + + + + + + + + +
AttributeDescriptionRequired
expandPropertiesWhether to expand properties in the nested text. + since Ant 1.8.0.No, defaults to true.

Examples

 <replace dir="${src}" value="wombat">
diff --git a/docs/manual/OptionalTasks/replaceregexp.html b/docs/manual/OptionalTasks/replaceregexp.html
index 1b668a945..e86224d71 100644
--- a/docs/manual/OptionalTasks/replaceregexp.html
+++ b/docs/manual/OptionalTasks/replaceregexp.html
@@ -90,7 +90,7 @@ See details in the documentation of the preserveLastModified
     Keep the file timestamp(s) even if the file(s)
-      is(are) modified.
+      is(are) modified.  since Ant 1.8.0.
     No, defaults to false
   
 
diff --git a/src/main/org/apache/tools/ant/taskdefs/Replace.java b/src/main/org/apache/tools/ant/taskdefs/Replace.java
index 5bbc7f9fb..4efe38552 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Replace.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Replace.java
@@ -86,8 +86,23 @@ public class Replace extends MatchingTask {
      */
     public class NestedString {
 
+        private boolean expandProperties = false;
         private StringBuffer buf = new StringBuffer();
 
+        /**
+         * Whether properties should be expanded in nested test.
+         *
+         * 

If you use this class via its Java interface the text + * you add via {@link #addText addText} has most likely been + * expanded already so you do not want to set this to + * true.

+ * + * @since Ant 1.8.0 + */ + public void setExpandProperties(boolean b) { + expandProperties = b; + } + /** * The text of the element. * @@ -101,7 +116,8 @@ public class Replace extends MatchingTask { * @return the text */ public String getText() { - return buf.toString(); + String s = buf.toString(); + return expandProperties ? getProject().replaceProperties(s) : s; } } diff --git a/src/tests/antunit/taskdefs/replace-test.xml b/src/tests/antunit/taskdefs/replace-test.xml index 52cf03c60..3f3090978 100644 --- a/src/tests/antunit/taskdefs/replace-test.xml +++ b/src/tests/antunit/taskdefs/replace-test.xml @@ -44,4 +44,27 @@ Hello, world! + + + + + + world + ${ant} + + + + + + + + + world + ${ant} + + + +