[maven-shade-plugin] branch master updated: [MSHADE-327] improved integration test coverage for relocation and minification (#27)

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[maven-shade-plugin] branch master updated: [MSHADE-327] improved integration test coverage for relocation and minification (#27)

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

olamy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git


The following commit(s) were added to refs/heads/master by this push:
     new b68b24c  [MSHADE-327] improved integration test coverage for relocation and minification (#27)
b68b24c is described below

commit b68b24c10ed0e57ce32c19248cfb38bd6c52d174
Author: Torsten Curdt <[hidden email]>
AuthorDate: Wed Sep 11 23:19:26 2019 +0200

    [MSHADE-327] improved integration test coverage for relocation and minification (#27)
   
    * adds an integration test that verifies relocation and minifying work together
   
    * reference the jira issue
   
    * upgraded to latest jdependency version 2.3.0,
    added me to the list of contributors
   
    * removed me as author
---
 pom.xml                                            |  5 +-
 src/it/reloc-and-mini/invoker.properties           | 18 +++++
 src/it/reloc-and-mini/pom.xml                      | 77 ++++++++++++++++++++++
 .../org/apache/maven/plugins/shade/its/App.java    | 31 +++++++++
 src/it/reloc-and-mini/verify.bsh                   | 50 ++++++++++++++
 .../maven/plugins/shade/filter/MinijarFilter.java  |  2 -
 6 files changed, 180 insertions(+), 3 deletions(-)

diff --git a/pom.xml b/pom.xml
index a01019b..d387e07 100644
--- a/pom.xml
+++ b/pom.xml
@@ -84,6 +84,9 @@
     <contributor>
       <name>Markus Karg</name>
     </contributor>
+    <contributor>
+      <name>Torsten Curdt</name>
+    </contributor>
   </contributors>
 
   <dependencies>
@@ -156,7 +159,7 @@
     <dependency>
       <groupId>org.vafer</groupId>
       <artifactId>jdependency</artifactId>
-      <version>2.1.1</version>
+      <version>2.3.0</version>
     </dependency>
     <dependency>
       <groupId>org.codehaus.plexus</groupId>
diff --git a/src/it/reloc-and-mini/invoker.properties b/src/it/reloc-and-mini/invoker.properties
new file mode 100644
index 0000000..dd70de3
--- /dev/null
+++ b/src/it/reloc-and-mini/invoker.properties
@@ -0,0 +1,18 @@
+# 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.
+
+invoker.java.version = 1.8+
diff --git a/src/it/reloc-and-mini/pom.xml b/src/it/reloc-and-mini/pom.xml
new file mode 100644
index 0000000..2227b80
--- /dev/null
+++ b/src/it/reloc-and-mini/pom.xml
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+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.
+-->
+<project>
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.maven.plugins.shade.its</groupId>
+    <artifactId>shade-parent</artifactId>
+    <version>1.0</version>
+    <relativePath>../setup-parent</relativePath>
+  </parent>
+
+  <groupId>org.apache.maven.its.shade.mini</groupId>
+  <artifactId>test</artifactId>
+  <version>1.0</version>
+  <packaging>jar</packaging>
+
+  <name>MSHADE-327</name>
+  <description>
+    Test handling of relocations and minification.
+  </description>
+
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.2</version>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-shade-plugin</artifactId>
+        <version>@project.version@</version>
+        <executions>
+          <execution>
+            <id>attach-shade</id>
+            <phase>package</phase>
+            <goals>
+              <goal>shade</goal>
+            </goals>
+            <configuration>
+              <minimizeJar>true</minimizeJar>
+              <shadedArtifactAttached>false</shadedArtifactAttached>
+              <relocations>
+                <relocation>
+                  <pattern>junit.framework</pattern>
+                  <shadedPattern>a.junit.framework</shadedPattern>
+                </relocation>
+              </relocations>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/src/it/reloc-and-mini/src/main/java/org/apache/maven/plugins/shade/its/App.java b/src/it/reloc-and-mini/src/main/java/org/apache/maven/plugins/shade/its/App.java
new file mode 100644
index 0000000..7ff0233
--- /dev/null
+++ b/src/it/reloc-and-mini/src/main/java/org/apache/maven/plugins/shade/its/App.java
@@ -0,0 +1,31 @@
+package org.apache.maven.plugins.shade.its;
+
+/*
+ * 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 junit.framework.TestResult;
+
+public class App
+{
+    public static void main( String[] args )
+    {
+        TestResult result = new TestResult();
+        System.out.println("Failures: " + result.failureCount());
+    }
+}
diff --git a/src/it/reloc-and-mini/verify.bsh b/src/it/reloc-and-mini/verify.bsh
new file mode 100644
index 0000000..ae85d02
--- /dev/null
+++ b/src/it/reloc-and-mini/verify.bsh
@@ -0,0 +1,50 @@
+/*
+ * 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.*;
+
+String[] wanted =
+{
+    "a/junit/framework/TestResult.class",
+};
+
+String[] unwanted =
+{
+    "junit/framework/TestResult.class",
+};
+
+JarFile jarFile = new JarFile( new File( basedir, "target/test-1.0.jar" ) );
+
+for ( String path : wanted )
+{
+    if ( jarFile.getEntry( path ) == null )
+    {
+        throw new IllegalStateException( "wanted path is missing: " + path );
+    }
+}
+
+for ( String path : unwanted )
+{
+    if ( jarFile.getEntry( path ) != null )
+    {
+        throw new IllegalStateException( "unwanted path is present: " + path );
+    }
+}
+
+jarFile.close();
diff --git a/src/main/java/org/apache/maven/plugins/shade/filter/MinijarFilter.java b/src/main/java/org/apache/maven/plugins/shade/filter/MinijarFilter.java
index 608924b..818339e 100644
--- a/src/main/java/org/apache/maven/plugins/shade/filter/MinijarFilter.java
+++ b/src/main/java/org/apache/maven/plugins/shade/filter/MinijarFilter.java
@@ -46,8 +46,6 @@ import java.util.zip.ZipException;
 
 /**
  * A filter that prevents the inclusion of classes not required in the final jar.
- *
- * @author Torsten Curdt
  */
 public class MinijarFilter
     implements Filter