You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kr...@apache.org on 2014/12/06 20:46:13 UTC

svn commit: r1643597 - /maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/format/ReaderFormatter.java

Author: krosenvold
Date: Sat Dec  6 19:46:13 2014
New Revision: 1643597

URL: http://svn.apache.org/r1643597
Log:
[MASSEMBLY-648] Fail when filtering line endings on jar/zip files

Modified:
    maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/format/ReaderFormatter.java

Modified: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/format/ReaderFormatter.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/format/ReaderFormatter.java?rev=1643597&r1=1643596&r2=1643597&view=diff
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/format/ReaderFormatter.java (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/format/ReaderFormatter.java Sat Dec  6 19:46:13 2014
@@ -39,7 +39,7 @@ import java.util.LinkedHashSet;
 import java.util.List;
 
 /**
- * 
+ *
  */
 public class ReaderFormatter
 {
@@ -91,9 +91,32 @@ public class ReaderFormatter
         }
     }
 
+
+    private static boolean isForbiddenFiletypes( PlexusIoResource plexusIoResource )
+        throws IOException
+    {
+        String fileName = plexusIoResource.getName().toLowerCase();
+        return ( fileName.endsWith( ".zip" ) || fileName.endsWith( ".jar" ) );
+    }
+
+    private static void checkifFileTypeIsAppropriateForLineEndingTransformation( PlexusIoResource plexusIoResource )
+        throws IOException
+    {
+        if ( isForbiddenFiletypes( plexusIoResource ) )
+        {
+            throw new IOException( "Cannot transform line endings on this kind of file: " + plexusIoResource.getName() +
+                                       "\nDoing so is more or less guaranteed to destroy the file, and it indicates a "
+                                       + "problem with your assembly descriptor."
+                                       + "\nThis error message is new as of 2.5.3. "
+                                       + "\nEarlier versions of assembly-plugin will silently destroy your file. "
+                                       + "Fix your descriptor" );
+        }
+
+    }
+
     @Nullable
     public static InputStreamTransformer getFileSetTransformers( final AssemblerConfigurationSource configSource,
-                                                   final boolean isFiltered, String fileSetLineEnding )
+                                                                 final boolean isFiltered, String fileSetLineEnding )
         throws AssemblyFormattingException
     {
         final LineEndings lineEndingToUse = LineEndingsUtils.getLineEnding( fileSetLineEnding );
@@ -125,6 +148,7 @@ public class ReaderFormatter
                     }
                     if ( transformLineEndings )
                     {
+                        checkifFileTypeIsAppropriateForLineEndingTransformation( plexusIoResource );
                         result = LineEndingsUtils.lineEndingConverter( result, lineEndingToUse );
                     }
                     return result;