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/14 08:03:52 UTC

[GitHub] [maven-shade-plugin] michael-o commented on a change in pull request #25: [MSHADE-36] Use reduced dependencies

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



##########
File path: src/it/MSHADE-36-inject-dep-reduced-pom-in-final/src/main/java/nl/example/Main.java
##########
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+package nl.example;

Review comment:
       Use `com.example`

##########
File path: src/it/MSHADE-36-inject-dep-reduced-pom-in-final/pom.xml
##########
@@ -0,0 +1,100 @@
+<?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.drp</groupId>
+  <artifactId>test</artifactId>
+  <version>1.0</version>
+  <packaging>jar</packaging>
+
+  <name>MSHADE-36</name>
+  <description>
+    Test to see that the dependency-reduced-pom.xml is injected into the final jar instead of the normal pom.xml
+  </description>
+
+  <properties>
+    <maven.compiler.source>1.4</maven.compiler.source>
+    <maven.compiler.target>1.4</maven.compiler.target>

Review comment:
       These should match the plugin's Java requirement.

##########
File path: src/it/MSHADE-36-inject-dep-reduced-pom-in-final/invoker.properties
##########
@@ -0,0 +1,19 @@
+# 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.goals = clean package
+invoker.java.version = 1.8+

Review comment:
       Why is that necessary?

##########
File path: src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java
##########
@@ -437,6 +447,24 @@ public void execute()
 
             List<ResourceTransformer> resourceTransformers = getResourceTransformers();
 
+            if ( createDependencyReducedPom )

Review comment:
       You have moved this before the Shader works. No changes in behavior?

##########
File path: src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java
##########
@@ -289,6 +291,14 @@
     @Parameter( defaultValue = "false" )
     private boolean generateUniqueDependencyReducedPom;
 
+    /**
+     * Do we put the dependency reduced pom in the jar instead of the jar file provided by the project.
+     *
+     * @since 3.2.2

Review comment:
       Update this one

##########
File path: src/main/java/org/apache/maven/plugins/shade/resource/UseDependencyReducedPomXml.java
##########
@@ -0,0 +1,54 @@
+package org.apache.maven.plugins.shade.resource;
+
+/*
+ * 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 org.apache.maven.project.MavenProject;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Manually creates the resource processors needed to remove the original pom.xml and inject
+ * the dependency-reduced-pom.xml in it's place in the shaded JAR.
+ */
+public class UseDependencyReducedPomXml

Review comment:
       Please name this `UseDependencyReducedPom`

##########
File path: src/it/MSHADE-36-inject-dep-reduced-pom-in-final/pom.xml
##########
@@ -0,0 +1,100 @@
+<?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.drp</groupId>
+  <artifactId>test</artifactId>
+  <version>1.0</version>
+  <packaging>jar</packaging>
+
+  <name>MSHADE-36</name>
+  <description>
+    Test to see that the dependency-reduced-pom.xml is injected into the final jar instead of the normal pom.xml

Review comment:
       normal => original




-- 
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