diff --git a/WHATSNEW b/WHATSNEW index febe07899..e43a57979 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -116,6 +116,11 @@ Other changes: * Tighten security by sending storepass and keypass to signjar via the input stream of the forked process. +* New task extends with extra support + for XML Schema (XSD) files. + +* supports a file attribute for easy fixup of a single file. + Changes from Ant 1.6.2 to current Ant 1.6 CVS version ===================================================== @@ -222,9 +227,6 @@ Other changes: * Pathconvert no longer requires that one of (targetos|pathsep|dirsep) be set; platform defaults are used when this is the case. - -* New task extends with extra support - for XML Schema (XSD) files. Fixed bugs: ----------- diff --git a/docs/manual/CoreTasks/fixcrlf.html b/docs/manual/CoreTasks/fixcrlf.html index afbf9c3ce..78ff157dd 100644 --- a/docs/manual/CoreTasks/fixcrlf.html +++ b/docs/manual/CoreTasks/fixcrlf.html @@ -51,8 +51,14 @@ supports all attributes of <fileset> srcDir Where to find the files to be fixed up. - Yes + Either file or srcDir + + file + Name of a single file to fix. Since Ant1.7 + Either file or srcDir + + destDir Where to place the corrected files. Defaults to diff --git a/src/etc/testcases/taskdefs/fixcrlf/build.xml b/src/etc/testcases/taskdefs/fixcrlf/build.xml index cdca01d55..823e58557 100644 --- a/src/etc/testcases/taskdefs/fixcrlf/build.xml +++ b/src/etc/testcases/taskdefs/fixcrlf/build.xml @@ -1,5 +1,5 @@ - + @@ -162,4 +162,12 @@ + + + + + + + + diff --git a/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java b/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java index c25dbc722..eaeb77adf 100644 --- a/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java +++ b/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java @@ -121,11 +121,13 @@ public class FixCRLF extends MatchingTask { private File srcDir; private File destDir = null; + private File file; /** * Encoding to assume for the files */ private String encoding = null; + public static final String ERROR_FILE_AND_SRCDIR = "srcdir and file are mutually exclusive"; /** * Defaults the properties based on the system type. @@ -172,6 +174,14 @@ public class FixCRLF extends MatchingTask { this.javafiles = javafiles; } + /** + * set a single file to convert + * @since Ant1.7 + * @param file + */ + public void setFile(File file) { + this.file = file; + } /** * Specify how EndOfLine characters are to be handled. @@ -314,6 +324,15 @@ public class FixCRLF extends MatchingTask { public void execute() throws BuildException { // first off, make sure that we've got a srcdir and destdir + if(file!=null) { + if(srcDir!=null) { + throw new BuildException(ERROR_FILE_AND_SRCDIR); + } + //patch file into the fileset + fileset.setFile(file); + //set our parent dir + srcDir=file.getParentFile(); + } if (srcDir == null) { throw new BuildException("srcdir attribute must be set!"); } @@ -745,7 +764,7 @@ public class FixCRLF extends MatchingTask { } - class OneLiner implements Enumeration { + protected class OneLiner implements Enumeration { private int state = javafiles ? LOOKING : NOTJAVA; diff --git a/src/testcases/org/apache/tools/ant/taskdefs/FixCrLfTest.java b/src/testcases/org/apache/tools/ant/taskdefs/FixCrLfTest.java index 16ad3dfd3..cc110918d 100644 --- a/src/testcases/org/apache/tools/ant/taskdefs/FixCrLfTest.java +++ b/src/testcases/org/apache/tools/ant/taskdefs/FixCrLfTest.java @@ -175,6 +175,18 @@ public class FixCrLfTest extends BuildFileTest { new File(System.getProperty("root"), "src/etc/testcases/taskdefs/fixcrlf/result/fixlastfalse.lf")); } + public void testFixFile() throws Exception { + executeTarget("testFixFile"); + File created= new File(System.getProperty("root"), + "src/etc/testcases/taskdefs/fixcrlf/result/longlines.crlf"); + assertTrue("didnt create output file",created.exists()); + } + + public void testFixFileExclusive() throws Exception { + expectBuildExceptionContaining("testFixFileExclusive", + FixCRLF.ERROR_FILE_AND_SRCDIR, FixCRLF.ERROR_FILE_AND_SRCDIR); + } + /** * Bugzilla Report 20840 *