Browse Source

Oops, used setProperty() instead of setNewProperty().

Thanks to Jan for the example on the userlist reminding me of my error.  ;)


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@277336 13f79535-47bb-0310-9956-ffa450edef68
master
Matthew Jason Benson 20 years ago
parent
commit
810c2bde30
3 changed files with 18 additions and 1 deletions
  1. +12
    -0
      src/etc/testcases/taskdefs/length.xml
  2. +2
    -1
      src/main/org/apache/tools/ant/taskdefs/Length.java
  3. +4
    -0
      src/testcases/org/apache/tools/ant/taskdefs/LengthTest.java

+ 12
- 0
src/etc/testcases/taskdefs/length.xml View File

@@ -104,6 +104,18 @@
<length string="foo" file="${ant.file}" /> <length string="foo" file="${ant.file}" />
</target> </target>


<target name="testImmutable">
<length string="foo" property="length.string" />
<length string="foobar" property="length.string" />
<fail>
<condition>
<not>
<equals arg1="3" arg2="${length.string}" />
</not>
</condition>
</fail>
</target>

<target name="cleanup"> <target name="cleanup">
<delete dir="${dir}" /> <delete dir="${dir}" />
</target> </target>


+ 2
- 1
src/main/org/apache/tools/ant/taskdefs/Length.java View File

@@ -190,7 +190,8 @@ public class Length extends Task {


private class PropertyOutputStream extends ByteArrayOutputStream { private class PropertyOutputStream extends ByteArrayOutputStream {
public void close() { public void close() {
getProject().setProperty(property, new String(toByteArray()).trim());
getProject().setNewProperty(
property, new String(toByteArray()).trim());
} }
} }




+ 4
- 0
src/testcases/org/apache/tools/ant/taskdefs/LengthTest.java View File

@@ -67,4 +67,8 @@ public class LengthTest extends BuildFileTest {
"should fail", "string length function only"); "should fail", "string length function only");
} }


public void testImmutable() {
executeTarget("testImmutable");
}

} }

Loading…
Cancel
Save