You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2020/06/29 21:14:36 UTC

[maven-shade-plugin] 01/01: [MSHADE-321] Always respect 'createDependencyReducedPom' flag

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

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

commit 09259ebd5a266f2a9fe8d9d720e4f72cc694e2f3
Author: head-thrash <il...@gmail.com>
AuthorDate: Sat May 25 00:46:07 2019 +0300

    [MSHADE-321] Always respect 'createDependencyReducedPom' flag
    
    This closes #22
---
 src/it/MSHADE-321_respectDrpFlag/pom.xml           |  84 +++++++++++++++++++++
 .../org/apache/maven/its/shade/drp/a/0.1/a-0.1.jar | Bin 0 -> 1945 bytes
 .../org/apache/maven/its/shade/drp/a/0.1/a-0.1.pom |  29 +++++++
 src/it/MSHADE-321_respectDrpFlag/verify.groovy     |  30 ++++++++
 .../apache/maven/plugins/shade/mojo/ShadeMojo.java |  10 +--
 5 files changed, 148 insertions(+), 5 deletions(-)

diff --git a/src/it/MSHADE-321_respectDrpFlag/pom.xml b/src/it/MSHADE-321_respectDrpFlag/pom.xml
new file mode 100644
index 0000000..b78cf34
--- /dev/null
+++ b/src/it/MSHADE-321_respectDrpFlag/pom.xml
@@ -0,0 +1,84 @@
+<?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>
+
+  <groupId>org.apache.maven.its.shade.drp</groupId>
+  <artifactId>test</artifactId>
+  <version>1.0</version>
+  <packaging>jar</packaging>
+
+  <name>MSHADE-321</name>
+  <description>
+    Test that dependency-reduced-pom is created with respect to flag only.
+
+    Shade plugin starts to create DRP even if the artifact has been renamed because of the configuration
+  </description>
+
+  <repositories>
+    <repository>
+      <id>shade-it</id>
+      <url>file:///${basedir}/repo</url>
+      <releases>
+        <checksumPolicy>ignore</checksumPolicy>
+      </releases>
+      <snapshots>
+        <enabled>false</enabled>
+      </snapshots>
+    </repository>
+  </repositories>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven.its.shade.drp</groupId>
+      <artifactId>a</artifactId>
+      <version>0.1</version>
+    </dependency>
+
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-shade-plugin</artifactId>
+        <version>@project.version@</version>
+        <executions>
+          <execution>
+            <id>shade</id>
+            <phase>package</phase>
+            <goals>
+              <goal>shade</goal>
+            </goals>
+            <configuration>
+              <promoteTransitiveDependencies>true</promoteTransitiveDependencies>
+              <finalName>shade_321</finalName>
+              <shadedArtifactAttached>false</shadedArtifactAttached>
+              <createDependencyReducedPom>true</createDependencyReducedPom>
+              <dependencyReducedPomLocation>target/shade_321.xml</dependencyReducedPomLocation>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/src/it/MSHADE-321_respectDrpFlag/repo/org/apache/maven/its/shade/drp/a/0.1/a-0.1.jar b/src/it/MSHADE-321_respectDrpFlag/repo/org/apache/maven/its/shade/drp/a/0.1/a-0.1.jar
new file mode 100644
index 0000000..9794e0e
Binary files /dev/null and b/src/it/MSHADE-321_respectDrpFlag/repo/org/apache/maven/its/shade/drp/a/0.1/a-0.1.jar differ
diff --git a/src/it/MSHADE-321_respectDrpFlag/repo/org/apache/maven/its/shade/drp/a/0.1/a-0.1.pom b/src/it/MSHADE-321_respectDrpFlag/repo/org/apache/maven/its/shade/drp/a/0.1/a-0.1.pom
new file mode 100644
index 0000000..1debd2f
--- /dev/null
+++ b/src/it/MSHADE-321_respectDrpFlag/repo/org/apache/maven/its/shade/drp/a/0.1/a-0.1.pom
@@ -0,0 +1,29 @@
+<?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>
+
+  <groupId>org.apache.maven.its.shade.drp</groupId>
+  <artifactId>a</artifactId>
+  <version>0.1</version>
+  <packaging>jar</packaging>
+</project>
diff --git a/src/it/MSHADE-321_respectDrpFlag/verify.groovy b/src/it/MSHADE-321_respectDrpFlag/verify.groovy
new file mode 100644
index 0000000..5a6c4cb
--- /dev/null
+++ b/src/it/MSHADE-321_respectDrpFlag/verify.groovy
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+File jarRenamedFile = new File(basedir, "target/shade_321.jar")
+assert jarRenamedFile.isFile()
+
+File pomFile = new File(basedir, "target/shade_321.xml")
+assert pomFile.isFile()
+
+def ns = new groovy.xml.Namespace("http://maven.apache.org/POM/4.0.0")
+def pom = new XmlParser().parse(pomFile)
+
+assert pom[ns.modelVersion].size() == 1
+assert pom[ns.dependencies][ns.dependency].size() == 0
diff --git a/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java b/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java
index 5e575e8..cf7cddf 100644
--- a/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java
+++ b/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java
@@ -593,13 +593,13 @@ public class ShadeMojo
                             projectHelper.attachArtifact( project, "java-source", "test-sources",
                                 shadedTestSources );
                         }
-
-                        if ( createDependencyReducedPom )
-                        {
-                            createDependencyReducedPom( artifactIds );
-                        }
                     }
                 }
+
+                if ( createDependencyReducedPom )
+                {
+                    createDependencyReducedPom( artifactIds );
+                }
             }
         }
         catch ( Exception e )