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
<include>, <exclude> and
Since Ant 1.8.0 this task supports any filesystem based resource collections as nested elements.
+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:
+| Attribute | +Description | +Required | +
| expandProperties | +Whether to expand properties in the nested text. + since Ant 1.8.0. | +No, defaults to true. | +
<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}
+
+
+
+