You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2021/06/18 20:50:56 UTC

[GitHub] [maven-shade-plugin] michael-o commented on a change in pull request #26: [MSHADE-326] Hide shaded dependencies from the rest of the reactor build

michael-o commented on a change in pull request #26:
URL: https://github.com/apache/maven-shade-plugin/pull/26#discussion_r654418515



##########
File path: src/it/projects/MSHADE-326-Hide-dependencies-from-reactor/verify.bsh
##########
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.*;
+import java.util.jar.*;
+import java.util.Arrays;
+import org.codehaus.plexus.util.*;
+
+String[] libraryWanted =
+{
+    "com/example/StringTester.class",
+    "com/example/shaded/org/codehaus/plexus/util/StringUtils.class",
+};
+
+String[] libraryUnwanted =
+{
+    "org/codehaus/plexus/util/StringUtils.class",
+};
+
+JarFile libraryJarFile = null;
+try
+{
+    libraryJarFile = new JarFile( new File( basedir, "library/target/library-1.0.jar" ) );
+
+    for ( String path : libraryWanted )
+    {
+        if ( libraryJarFile.getEntry( path ) == null )
+        {
+            throw new IllegalStateException( "Library: wanted path is missing: " + path );
+        }
+    }
+
+    for ( String path : libraryUnwanted )
+    {
+        if ( libraryJarFile.getEntry( path ) != null )
+        {
+            throw new IllegalStateException( "Library: unwanted path is present: " + path );
+        }
+    }
+
+    JarEntry jarEntry = libraryJarFile.getEntry( "META-INF/maven/org.apache.maven.its.shade.drp/library/pom.xml" );
+    String pomFile = IOUtil.toString( libraryJarFile.getInputStream( jarEntry ), "UTF-8" );
+
+    if ( pomFile.contains( "<groupId>org.codehaus.plexus</groupId>" ) ) {
+        throw new IllegalStateException( "The pom.xml still contains a reference to the org.codehaus.plexus dependency");
+    }
+}
+finally
+{
+    if ( libraryJarFile != null ) {
+        libraryJarFile.close();
+    }
+}
+
+

Review comment:
       I think this entire block is redudant because it duplicates the same test as in the previous PR. Where is the benefit here?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org