ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 5515] New: - Replace Task -- carriage returns
Date Wed, 19 Dec 2001 17:06:23 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=5515>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=5515

Replace Task -- carriage returns

           Summary: Replace Task -- carriage returns
           Product: Ant
           Version: 1.4.1
          Platform: Other
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Core tasks
        AssignedTo: ant-dev@jakarta.apache.org
        ReportedBy: sean@wingateweb.com


The problem:

I have a replace task, defined like this in my build.xml file:
    <replace file="${work-dir}/WEB-INF/web.xml" summary="true">
      <replacetoken><![CDATA[<param-name>mail-enabled</param-name>
      <param-value>false</param-value>]]></replacetoken>
      <replacevalue><![CDATA[<param-name>mail-enabled</param-name>
      <param-value>true</param-value>]]></replacevalue>
    </replace>
Although the replace token exists in my the source file, ant never replaces the 
token with my desired value.

I think it has something to do with the following code snippet 
(org.apache.tools.ant.taskdefs.Replace, line 324...):

                String linesep = System.getProperty("line.separator");
                String val = stringReplace(value.getText(), "\n", linesep);
                String tok = stringReplace(token.getText(), "\n", linesep);

                // for each found token, replace with value
                log("Replacing in " + src.getPath() + ": " + token.getText() 
+ " --> " + value.getText(), Project.MSG_VERBOSE);
                newString = stringReplace(newString, tok, val);


According to section 2.11 of the XML 1.0 spec, XML processors normalize end-of-
line characters for you, so the first three lines of this snippet are 
unnecessary. Unfortunately, I don't have a whole lot of time to figure out 
exactly why calling stringReplace with those parameters fails, but I did get it 
to work correctly by changing the last line of that code snippet to this:

newString = stringReplace(newString, token.getText(), value.getText());

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message