You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by de...@apache.org on 2012/10/28 23:05:39 UTC

svn commit: r1403107 - in /maven/plugins/trunk/maven-assembly-plugin/src: it/projects/file-sets/multimodule-unix-lineEndings/ it/projects/file-sets/multimodule-win-lineEndings/ main/java/org/apache/maven/plugin/assembly/utils/ test/java/org/apache/mave...

Author: dennisl
Date: Sun Oct 28 22:05:38 2012
New Revision: 1403107

URL: http://svn.apache.org/viewvc?rev=1403107&view=rev
Log:
[MASSEMBLY-96] using fileSet -> lineEnding will always put the selected lineEnding at the end of the file, even if the original file does not end in one

Modified:
    maven/plugins/trunk/maven-assembly-plugin/src/it/projects/file-sets/multimodule-unix-lineEndings/verify.bsh
    maven/plugins/trunk/maven-assembly-plugin/src/it/projects/file-sets/multimodule-win-lineEndings/verify.bsh
    maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/utils/AssemblyFileUtils.java
    maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/format/FileFormatterTest.java
    maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/format/FileSetFormatterTest.java
    maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/utils/AssemblyFileUtilsTest.java

Modified: maven/plugins/trunk/maven-assembly-plugin/src/it/projects/file-sets/multimodule-unix-lineEndings/verify.bsh
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/it/projects/file-sets/multimodule-unix-lineEndings/verify.bsh?rev=1403107&r1=1403106&r2=1403107&view=diff
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/it/projects/file-sets/multimodule-unix-lineEndings/verify.bsh (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/it/projects/file-sets/multimodule-unix-lineEndings/verify.bsh Sun Oct 28 22:05:38 2012
@@ -22,4 +22,14 @@ reader.close();
 
 System.out.println( "Contents of test.txt: '" + sb.toString() + "' should contain the unix newline: '\\n'." );
 
-return sb.toString().indexOf( "1\nchild" ) > -1;
\ No newline at end of file
+if ( sb.toString().indexOf( "1\nchild" ) == -1 )
+{
+    System.out.println( "test.txt has wrong line ending" );
+    return false;
+}
+if ( sb.toString().indexOf( "child\n" ) > -1 )
+{
+    System.out.println( "test.txt has an extra line ending at the end of the file" );
+    return false;
+}
+return true;
\ No newline at end of file

Modified: maven/plugins/trunk/maven-assembly-plugin/src/it/projects/file-sets/multimodule-win-lineEndings/verify.bsh
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/it/projects/file-sets/multimodule-win-lineEndings/verify.bsh?rev=1403107&r1=1403106&r2=1403107&view=diff
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/it/projects/file-sets/multimodule-win-lineEndings/verify.bsh (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/it/projects/file-sets/multimodule-win-lineEndings/verify.bsh Sun Oct 28 22:05:38 2012
@@ -22,4 +22,14 @@ reader.close();
 
 System.out.println( "Contents of test.txt: '" + sb.toString() + "' should contain the windows newline: '\\r\\n'." );
 
-return sb.toString().indexOf( "1\r\nchild" ) > -1;
\ No newline at end of file
+if ( sb.toString().indexOf( "1\r\nchild" ) == -1 )
+{
+    System.out.println( "test.txt has wrong line ending" );
+    return false;
+}
+if ( sb.toString().indexOf( "child\r\n" ) > -1 )
+{
+    System.out.println( "test.txt has an extra line ending at the end of the file" );
+    return false;
+}
+return true;
\ No newline at end of file

Modified: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/utils/AssemblyFileUtils.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/utils/AssemblyFileUtils.java?rev=1403107&r1=1403106&r2=1403107&view=diff
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/utils/AssemblyFileUtils.java (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/utils/AssemblyFileUtils.java Sun Oct 28 22:05:38 2012
@@ -155,15 +155,16 @@ public final class AssemblyFileUtils
 
             String line;
 
-            do
+            line = bufferedSource.readLine();
+            while ( line != null )
             {
+                out.write( line );
                 line = bufferedSource.readLine();
                 if ( line != null )
                 {
-                    out.write( line );
                     out.write( lineEndings );
                 }
-            } while ( line != null );
+            }
 
             out.flush();
         }

Modified: maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/format/FileFormatterTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/format/FileFormatterTest.java?rev=1403107&r1=1403106&r2=1403107&view=diff
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/format/FileFormatterTest.java (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/format/FileFormatterTest.java Sun Oct 28 22:05:38 2012
@@ -113,7 +113,6 @@ public class FileFormatterTest
         mockManager.verifyAll();
     }
 
-    // TODO: Should not be appending line-ending at the end if there is none in the source.
     public void testShouldConvertCRLFLineEndingsInFile() throws IOException, AssemblyFormattingException
     {
         final File basedir = fileManager.createTempDir();
@@ -127,12 +126,11 @@ public class FileFormatterTest
 
         final File result = new FileFormatter( configSource, logger ).format( file, false, "dos", "UTF-8" );
 
-        assertEquals( "This is a\r\ntest.\r\n", fileManager.getFileContents( result ) );
+        assertEquals( "This is a\r\ntest.", fileManager.getFileContents( result ) );
 
         mockManager.verifyAll();
     }
 
-    // TODO: Should not be appending line-ending at the end if there is none in the source.
     public void testShouldConvertLFLineEndingsInFile() throws IOException, AssemblyFormattingException
     {
         final File basedir = fileManager.createTempDir();
@@ -146,7 +144,7 @@ public class FileFormatterTest
 
         final File result = new FileFormatter( configSource, logger ).format( file, false, "unix", "UTF-8" );
 
-        assertEquals( "This is a\ntest.\n", fileManager.getFileContents( result ) );
+        assertEquals( "This is a\ntest.", fileManager.getFileContents( result ) );
 
         mockManager.verifyAll();
     }

Modified: maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/format/FileSetFormatterTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/format/FileSetFormatterTest.java?rev=1403107&r1=1403106&r2=1403107&view=diff
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/format/FileSetFormatterTest.java (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/format/FileSetFormatterTest.java Sun Oct 28 22:05:38 2012
@@ -153,8 +153,8 @@ public class FileSetFormatterTest
 
         try
         {
-            fileManager.assertFileContents( result, filename1, "Hello\r\nThis is a test.\r\n" );
-            fileManager.assertFileContents( result, filename2, "Hello\r\nThis is also a test.\r\n" );
+            fileManager.assertFileContents( result, filename1, "Hello\r\nThis is a test." );
+            fileManager.assertFileContents( result, filename2, "Hello\r\nThis is also a test." );
         }
         finally
         {
@@ -195,7 +195,7 @@ public class FileSetFormatterTest
 
         try
         {
-            fileManager.assertFileContents( result, filename1, "Hello\r\nThis is a test.\r\n" );
+            fileManager.assertFileContents( result, filename1, "Hello\r\nThis is a test." );
             fileManager.assertFileExistence( result, filename2, false );
         }
         finally
@@ -236,7 +236,7 @@ public class FileSetFormatterTest
         assertFalse( dir.equals( result ) );
         try
         {
-            fileManager.assertFileContents( result, filename1, "Hello\r\nThis is a test.\r\n" );
+            fileManager.assertFileContents( result, filename1, "Hello\r\nThis is a test." );
             fileManager.assertFileExistence( result, filename2, false );
         }
         finally
@@ -277,7 +277,7 @@ public class FileSetFormatterTest
 
         try
         {
-            fileManager.assertFileContents( result, filename1, "Hello\r\nThis is a test.\r\n" );
+            fileManager.assertFileContents( result, filename1, "Hello\r\nThis is a test." );
             fileManager.assertFileExistence( result, filename2, false );
         }
         finally

Modified: maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/utils/AssemblyFileUtilsTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/utils/AssemblyFileUtilsTest.java?rev=1403107&r1=1403106&r2=1403107&view=diff
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/utils/AssemblyFileUtilsTest.java (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/utils/AssemblyFileUtilsTest.java Sun Oct 28 22:05:38 2012
@@ -130,42 +130,38 @@ public class AssemblyFileUtilsTest
         }
     }
 
-    // TODO: Fix the end-of-document problem with line-ending conversions.
     public void testConvertLineEndings_ShouldReplaceLFWithCRLF()
         throws IOException
     {
         String test = "This is a \ntest.";
-        String check = "This is a \r\ntest.\r\n";
+        String check = "This is a \r\ntest.";
 
         testConversion( test, check, "\r\n" );
     }
 
-    // TODO: Fix the end-of-document problem with line-ending conversions.
     public void testConvertLineEndings_ShouldReplaceCRLFWithLF()
         throws IOException
     {
         String test = "This is a \r\ntest.";
-        String check = "This is a \ntest.\n";
+        String check = "This is a \ntest.";
 
         testConversion( test, check, "\n" );
     }
 
-    // TODO: Fix the end-of-document problem with line-ending conversions.
     public void testConvertLineEndings_ShouldReplaceLFWithLF()
         throws IOException
     {
         String test = "This is a \ntest.";
-        String check = "This is a \ntest.\n";
+        String check = "This is a \ntest.";
 
         testConversion( test, check, "\n" );
     }
 
-    // TODO: Fix the end-of-document problem with line-ending conversions.
     public void testConvertLineEndings_ShouldReplaceCRLFWithCRLF()
         throws IOException
     {
         String test = "This is a \r\ntest.";
-        String check = "This is a \r\ntest.\r\n";
+        String check = "This is a \r\ntest.";
 
         testConversion( test, check, "\r\n" );
     }