diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 465babc81..a74376d9f 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -219,6 +219,7 @@ Stephane Bailliez stephan Stephan Michels Stephen Chin +Stephen Goetze Steve Cohen Steve Loughran Steve Morin diff --git a/WHATSNEW b/WHATSNEW index bfcb25071..6f0be0e06 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -442,6 +442,8 @@ Other changes: * -created scripts have support for nested text. All text passed to a scripted task can be accessed via self.text. +* now supports an outputencoding attribute. Bugzilla report 39697. + Changes from Ant 1.6.4 to Ant 1.6.5 =================================== diff --git a/docs/manual/CoreTasks/fixcrlf.html b/docs/manual/CoreTasks/fixcrlf.html index 8bf6ab1ff..e828a22f3 100644 --- a/docs/manual/CoreTasks/fixcrlf.html +++ b/docs/manual/CoreTasks/fixcrlf.html @@ -121,6 +121,13 @@ No; defaults to default JVM encoding.   + + outputencoding + The encoding to use when writing the files. + Since Ant 1.7 + No; defaults to the value of the encoding attribute. +   + preservelastmodified Whether to preserve the last modified @@ -143,10 +150,11 @@
  • unix: convert all EOLs to a single LF
  • dos: convert all EOLs to the pair CRLF
  • - Default is based on the platform on which you are running - this task. For Unix platforms, the default is "lf". - For DOS based systems (including Windows), the default is - "crlf". For Mac OS, the default is "cr". + Default is based on the platform on which you are running this task. + For Unix platforms (including Mac OS X), the default is "lf". + For DOS-based systems (including Windows), the default is + "crlf". + For Mac environments other than OS X, the default is "cr".

    This is the preferred method for specifying EOL. The "cr" attribute (see below) is @@ -298,7 +306,7 @@ DOS systems, and are removed if run on Unix systems. You never know what editor a user will use to browse READMEs.


    -

    Copyright © 2000-2005 The Apache Software Foundation. All rights +

    Copyright © 2000-2006 The Apache Software Foundation. All rights Reserved.

    diff --git a/src/etc/testcases/taskdefs/fixcrlf/build.xml b/src/etc/testcases/taskdefs/fixcrlf/build.xml index 1ffb6592b..f3d8cf537 100644 --- a/src/etc/testcases/taskdefs/fixcrlf/build.xml +++ b/src/etc/testcases/taskdefs/fixcrlf/build.xml @@ -117,6 +117,15 @@ file2="expected/input.lf.utf16" /> + + + + + tab *
  • eof *
  • encoding + *
  • targetencoding * * Of these arguments, only sourcedir is required. *

    @@ -98,6 +99,11 @@ public class FixCRLF extends MatchingTask implements ChainableReader { */ private String encoding = null; + /** + * Encoding to use for output files + */ + private String outputEncoding = null; + /** * Chain this task as a reader. * @param rdr Reader to chain. @@ -237,6 +243,15 @@ public class FixCRLF extends MatchingTask implements ChainableReader { this.encoding = encoding; } + /** + * Specifies the encoding that the files are + * to be written in--same as input encoding by default. + * @param outputEncoding String outputEncoding name. + */ + public void setOutputEncoding(String outputEncoding) { + this.outputEncoding = outputEncoding; + } + /** * Specify whether a missing EOL will be added * to the final line of a file. @@ -288,12 +303,15 @@ public class FixCRLF extends MatchingTask implements ChainableReader { } } // log options used + String enc = encoding == null ? "default" : encoding; log("options:" + " eol=" + filter.getEol().getValue() + " tab=" + filter.getTab().getValue() + " eof=" + filter.getEof().getValue() + " tablength=" + filter.getTablength() - + " encoding=" + (encoding == null ? "default" : encoding), + + " encoding=" + enc + + " outputencoding=" + + (outputEncoding == null ? enc : outputEncoding), Project.MSG_VERBOSE); DirectoryScanner ds = super.getDirectoryScanner(srcDir); @@ -318,8 +336,9 @@ public class FixCRLF extends MatchingTask implements ChainableReader { File tmpFile = FILE_UTILS.createTempFile("fixcrlf", "", null); tmpFile.deleteOnExit(); try { - FILE_UTILS.copyFile(srcFile, tmpFile, null, fcv, false, - false, encoding, getProject()); + FILE_UTILS.copyFile(srcFile, tmpFile, null, fcv, false, false, + encoding, outputEncoding == null ? encoding : outputEncoding, + getProject()); File destFile = new File(destD, file); diff --git a/src/testcases/org/apache/tools/ant/taskdefs/FixCrLfTest.java b/src/testcases/org/apache/tools/ant/taskdefs/FixCrLfTest.java index d598522e3..f0a7eae99 100644 --- a/src/testcases/org/apache/tools/ant/taskdefs/FixCrLfTest.java +++ b/src/testcases/org/apache/tools/ant/taskdefs/FixCrLfTest.java @@ -91,6 +91,10 @@ public class FixCrLfTest extends BuildFileTest { executeTarget("testEncoding"); } + public void testOutputEncoding() throws IOException { + executeTarget("testOutputEncoding"); + } + public void testLongLines() throws IOException { executeTarget("testLongLines"); }