[MSHADE-302] maven-shade-plugin fails to minimize JAR with Java 11, upgrade jdependen...
authorolivier lamy <olamy@apache.org>
Tue, 6 Nov 2018 02:30:18 +0000 (12:30 +1000)
committerolivier lamy <olamy@apache.org>
Tue, 6 Nov 2018 02:30:18 +0000 (12:30 +1000)
Signed-off-by: olivier lamy <olamy@apache.org>
pom.xml
src/it/mini-jar-jdk11/invoker.properties [new file with mode: 0644]
src/it/mini-jar-jdk11/pom.xml [new file with mode: 0644]
src/it/mini-jar-jdk11/src/main/java/Main.java [new file with mode: 0644]
src/it/mini-jar-jdk11/verify.bsh [new file with mode: 0644]

diff --git a/pom.xml b/pom.xml
index f2fa536..fba4a8f 100644 (file)
--- a/pom.xml
+++ b/pom.xml
     <dependency>
       <groupId>org.vafer</groupId>
       <artifactId>jdependency</artifactId>
-      <version>2.0</version>
+      <version>2.1.1</version>
     </dependency>
     <dependency>
       <groupId>org.codehaus.plexus</groupId>
diff --git a/src/it/mini-jar-jdk11/invoker.properties b/src/it/mini-jar-jdk11/invoker.properties
new file mode 100644 (file)
index 0000000..1c24cc3
--- /dev/null
@@ -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 = 11+
diff --git a/src/it/mini-jar-jdk11/pom.xml b/src/it/mini-jar-jdk11/pom.xml
new file mode 100644 (file)
index 0000000..1b1db8b
--- /dev/null
@@ -0,0 +1,82 @@
+<?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.mj</groupId>
+  <artifactId>testmini-jdk11</artifactId>
+  <version>1.0</version>
+  <packaging>jar</packaging>
+
+  <name>MSHADE-302</name>
+  <description>
+    Test that artifact contents can be filtered automatically to produce a mini jar compiled with jdk11 that only
+    contains the referenced classes.
+  </description>
+
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.2</version>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>3.8.0</version>
+        <configuration>
+          <source>11</source>
+          <target>11</target>
+          <release>11</release>
+        </configuration>
+      </plugin>
+      <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>
+              <shadedArtifactAttached>false</shadedArtifactAttached>
+              <minimizeJar>true</minimizeJar>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/src/it/mini-jar-jdk11/src/main/java/Main.java b/src/it/mini-jar-jdk11/src/main/java/Main.java
new file mode 100644 (file)
index 0000000..2c15003
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+
+public class Main extends junit.framework.TestCase
+{
+    static class Nested { // Trigger MSHADE-302
+    }
+}
diff --git a/src/it/mini-jar-jdk11/verify.bsh b/src/it/mini-jar-jdk11/verify.bsh
new file mode 100644 (file)
index 0000000..abd8c66
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * 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 =
+{
+    "Main.class",
+    "Main$Nested.class",
+    "junit/framework/TestCase.class",
+    "junit/swingui/icons/error.gif",
+};
+
+String[] unwanted =
+{
+    "junit/swingui/TestRunner.class",
+};
+
+JarFile jarFile = new JarFile( new File( basedir, "target/testmini-jdk11-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();