You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rm...@apache.org on 2019/08/14 07:50:02 UTC

[maven-shade-plugin] 02/02: fixing Tibor's review comments (thanks) and ensuring test works on windows

This is an automated email from the ASF dual-hosted git repository.

rmannibucau pushed a commit to branch MSHADE-322_2
in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git

commit e300c0438b401ebd977f7157f925f4b8a3f1caba
Author: Romain Manni-Bucau <rm...@apache.org>
AuthorDate: Wed Aug 14 09:49:45 2019 +0200

    fixing Tibor's review comments (thanks) and ensuring test works on windows
---
 .../plugins/shade/resource/properties/SortedProperties.java |  9 ++++++---
 .../org/apache/maven/plugins/shade/DefaultShaderTest.java   | 13 ++++++-------
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/src/main/java/org/apache/maven/plugins/shade/resource/properties/SortedProperties.java b/src/main/java/org/apache/maven/plugins/shade/resource/properties/SortedProperties.java
index 48eb5f0..f64f9f7 100644
--- a/src/main/java/org/apache/maven/plugins/shade/resource/properties/SortedProperties.java
+++ b/src/main/java/org/apache/maven/plugins/shade/resource/properties/SortedProperties.java
@@ -23,8 +23,8 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.Enumeration;
-import java.util.HashSet;
 import java.util.Iterator;
+import java.util.LinkedHashSet;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
@@ -32,7 +32,10 @@ import java.util.Properties;
 import java.util.Set;
 
 /**
- * Properties instance sorting its keys on iterations.
+ * Internal Properties instance sorting its keys on iterations for store() usages.
+ * It ensures properties persistence is deterministic.
+ *
+ * IMPORTANT: this only overrides methods used accross JVM in store() so ordering is not guaranteed for other cases.
  */
 public class SortedProperties extends Properties
 {
@@ -48,7 +51,7 @@ public class SortedProperties extends Properties
                 return String.valueOf( o1.getKey() ).compareTo( String.valueOf( o2.getKey() ) );
             }
         } );
-        return new HashSet<>( entries );
+        return new LinkedHashSet<>( entries );
     }
 
     @Override
diff --git a/src/test/java/org/apache/maven/plugins/shade/DefaultShaderTest.java b/src/test/java/org/apache/maven/plugins/shade/DefaultShaderTest.java
index 54be8dd..e736d6a 100644
--- a/src/test/java/org/apache/maven/plugins/shade/DefaultShaderTest.java
+++ b/src/test/java/org/apache/maven/plugins/shade/DefaultShaderTest.java
@@ -65,7 +65,7 @@ public class DefaultShaderTest
             @Override
             public void debug( final String s, final Throwable throwable )
             {
-                debugMessages.add(s);
+                debugMessages.add( s.replace( '\\', '/' ).trim() );
             }
 
             @Override
@@ -77,7 +77,7 @@ public class DefaultShaderTest
             @Override
             public void warn( final String s, final Throwable throwable )
             {
-                warnMessages.add(s);
+                warnMessages.add( s.replace( '\\', '/' ).trim() );
             }
 
             @Override
@@ -101,7 +101,7 @@ public class DefaultShaderTest
 
         // we will shade two jars and expect to see META-INF/MANIFEST.MF overlaps, this will always be true
         // but this can lead to a broken deployment if intended for OSGi or so, so even this should be logged
-        final Set<File> set = new LinkedHashSet<File>();
+        final Set<File> set = new LinkedHashSet<>();
         set.add( new File( "src/test/jars/test-project-1.0-SNAPSHOT.jar" ) );
         set.add( new File( "src/test/jars/plexus-utils-1.4.1.jar" ) );
 
@@ -115,13 +115,12 @@ public class DefaultShaderTest
 
         final String failureWarnMessage = warnMessages.toString();
         assertTrue(failureWarnMessage, warnMessages.contains(
-                "plexus-utils-1.4.1.jar, test-project-1.0-SNAPSHOT.jar define 1 overlapping resources: "));
-        assertTrue(failureWarnMessage, warnMessages.contains("  - META-INF/MANIFEST.MF"));
+                "plexus-utils-1.4.1.jar, test-project-1.0-SNAPSHOT.jar define 1 overlapping resources:"));
+        assertTrue(failureWarnMessage, warnMessages.contains("- META-INF/MANIFEST.MF"));
 
         final String failureDebugMessage = debugMessages.toString();
         assertTrue(failureDebugMessage, debugMessages.contains(
-                "We have a duplicate META-INF/MANIFEST.MF in src/test/jars/plexus-utils-1.4.1.jar"
-                        .replace('/', File.separatorChar)));
+                "We have a duplicate META-INF/MANIFEST.MF in src/test/jars/plexus-utils-1.4.1.jar" ));
     }
 
     public void testShaderWithDefaultShadedPattern()