This is an automated email from the ASF dual-hosted git repository. khmarbaise pushed a commit to branch MSHADE-339 in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git
commit dc9dfa38e4695873d2a0c70aa77d6ed76c2d60c3 Author: Falko Modler <[email protected]> AuthorDate: Fri Jan 3 15:51:42 2020 +0100 [MSHADE-311] - Don't add exclusions for provided dep --- .../pom.xml | 105 +++++++++++++++++++++ .../apache/maven/its/shade/drpape/a/0.1/a-0.1.jar | Bin 0 -> 2020 bytes .../apache/maven/its/shade/drpape/a/0.1/a-0.1.pom | 40 ++++++++ .../apache/maven/its/shade/drpape/b/0.1/b-0.1.jar | Bin 0 -> 2053 bytes .../apache/maven/its/shade/drpape/b/0.1/b-0.1.pom | 48 ++++++++++ .../apache/maven/its/shade/drpape/c/0.1/c-0.1.jar | Bin 0 -> 2019 bytes .../apache/maven/its/shade/drpape/c/0.1/c-0.1.pom | 40 ++++++++ .../apache/maven/its/shade/drpape/d/0.1/d-0.1.jar | Bin 0 -> 2053 bytes .../apache/maven/its/shade/drpape/d/0.1/d-0.1.pom | 48 ++++++++++ .../apache/maven/its/shade/drpape/e/0.1/e-0.1.jar | Bin 0 -> 2020 bytes .../apache/maven/its/shade/drpape/e/0.1/e-0.1.pom | 40 ++++++++ .../verify.groovy | 40 ++++++++ .../apache/maven/plugins/shade/mojo/ShadeMojo.java | 6 +- 13 files changed, 366 insertions(+), 1 deletion(-) diff --git a/src/it/dep-reduced-pom-artifactset-provided-excludes/pom.xml b/src/it/dep-reduced-pom-artifactset-provided-excludes/pom.xml new file mode 100644 index 0000000..cc862c5 --- /dev/null +++ b/src/it/dep-reduced-pom-artifactset-provided-excludes/pom.xml @@ -0,0 +1,105 @@ +<?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.drpape</groupId> + <artifactId>test</artifactId> + <version>1.0</version> + <packaging>jar</packaging> + + <name>MSHADE-311</name> + <description> + Tests that creation of the dependency reduced POM does not create excludes for a provided transitive dependency. + This dependency 'c' is a compile dependency of 'b' which is a provided dependency of this project. + Shade-plugin is configured to only include (compile) dependency 'a', not 'b' (which must therefore be retained). + Additionally (to prevent regressions), this project has a provided dependency 'd' which depends on 'e', but 'e' is excluded. + That exclusion must be retained in the dependency reduced POM. + </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.drpape</groupId> + <artifactId>a</artifactId> + <version>0.1</version> + </dependency> + <dependency> + <groupId>org.apache.maven.its.shade.drpape</groupId> + <artifactId>b</artifactId> + <version>0.1</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.maven.its.shade.drpape</groupId> + <artifactId>d</artifactId> + <version>0.1</version> + <scope>provided</scope> + <exclusions> + <exclusion> + <groupId>org.apache.maven.its.shade.drpape</groupId> + <artifactId>e</artifactId> + </exclusion> + </exclusions> + </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> + <createDependencyReducedPom>true</createDependencyReducedPom> + <dependencyReducedPomLocation>target/dependency-reduced-pom.xml</dependencyReducedPomLocation> + <artifactSet> + <includes> + <include>org.apache.maven.its.shade.drpape:a</include> + </includes> + </artifactSet> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> diff --git a/src/it/dep-reduced-pom-artifactset-provided-excludes/repo/org/apache/maven/its/shade/drpape/a/0.1/a-0.1.jar b/src/it/dep-reduced-pom-artifactset-provided-excludes/repo/org/apache/maven/its/shade/drpape/a/0.1/a-0.1.jar new file mode 100644 index 0000000..484889c Binary files /dev/null and b/src/it/dep-reduced-pom-artifactset-provided-excludes/repo/org/apache/maven/its/shade/drpape/a/0.1/a-0.1.jar differ diff --git a/src/it/dep-reduced-pom-artifactset-provided-excludes/repo/org/apache/maven/its/shade/drpape/a/0.1/a-0.1.pom b/src/it/dep-reduced-pom-artifactset-provided-excludes/repo/org/apache/maven/its/shade/drpape/a/0.1/a-0.1.pom new file mode 100644 index 0000000..c943daa --- /dev/null +++ b/src/it/dep-reduced-pom-artifactset-provided-excludes/repo/org/apache/maven/its/shade/drpape/a/0.1/a-0.1.pom @@ -0,0 +1,40 @@ +<?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.drpape</groupId> + <artifactId>a</artifactId> + <version>0.1</version> + <packaging>jar</packaging> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + + <distributionManagement> + <repository> + <id>maven-core-it</id> + <url>file:///${basedir}/repo</url> + </repository> + </distributionManagement> +</project> diff --git a/src/it/dep-reduced-pom-artifactset-provided-excludes/repo/org/apache/maven/its/shade/drpape/b/0.1/b-0.1.jar b/src/it/dep-reduced-pom-artifactset-provided-excludes/repo/org/apache/maven/its/shade/drpape/b/0.1/b-0.1.jar new file mode 100644 index 0000000..c982180 Binary files /dev/null and b/src/it/dep-reduced-pom-artifactset-provided-excludes/repo/org/apache/maven/its/shade/drpape/b/0.1/b-0.1.jar differ diff --git a/src/it/dep-reduced-pom-artifactset-provided-excludes/repo/org/apache/maven/its/shade/drpape/b/0.1/b-0.1.pom b/src/it/dep-reduced-pom-artifactset-provided-excludes/repo/org/apache/maven/its/shade/drpape/b/0.1/b-0.1.pom new file mode 100644 index 0000000..09cb49b --- /dev/null +++ b/src/it/dep-reduced-pom-artifactset-provided-excludes/repo/org/apache/maven/its/shade/drpape/b/0.1/b-0.1.pom @@ -0,0 +1,48 @@ +<?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.drpape</groupId> + <artifactId>b</artifactId> + <version>0.1</version> + <packaging>jar</packaging> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + + <dependencies> + <dependency> + <groupId>org.apache.maven.its.shade.drpape</groupId> + <artifactId>c</artifactId> + <version>0.1</version> + </dependency> + </dependencies> + + <distributionManagement> + <repository> + <id>maven-core-it</id> + <url>file:///${basedir}/repo</url> + </repository> + </distributionManagement> +</project> diff --git a/src/it/dep-reduced-pom-artifactset-provided-excludes/repo/org/apache/maven/its/shade/drpape/c/0.1/c-0.1.jar b/src/it/dep-reduced-pom-artifactset-provided-excludes/repo/org/apache/maven/its/shade/drpape/c/0.1/c-0.1.jar new file mode 100644 index 0000000..520a93d Binary files /dev/null and b/src/it/dep-reduced-pom-artifactset-provided-excludes/repo/org/apache/maven/its/shade/drpape/c/0.1/c-0.1.jar differ diff --git a/src/it/dep-reduced-pom-artifactset-provided-excludes/repo/org/apache/maven/its/shade/drpape/c/0.1/c-0.1.pom b/src/it/dep-reduced-pom-artifactset-provided-excludes/repo/org/apache/maven/its/shade/drpape/c/0.1/c-0.1.pom new file mode 100644 index 0000000..49d9dea --- /dev/null +++ b/src/it/dep-reduced-pom-artifactset-provided-excludes/repo/org/apache/maven/its/shade/drpape/c/0.1/c-0.1.pom @@ -0,0 +1,40 @@ +<?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.drpape</groupId> + <artifactId>c</artifactId> + <version>0.1</version> + <packaging>jar</packaging> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + + <distributionManagement> + <repository> + <id>maven-core-it</id> + <url>file:///${basedir}/repo</url> + </repository> + </distributionManagement> +</project> diff --git a/src/it/dep-reduced-pom-artifactset-provided-excludes/repo/org/apache/maven/its/shade/drpape/d/0.1/d-0.1.jar b/src/it/dep-reduced-pom-artifactset-provided-excludes/repo/org/apache/maven/its/shade/drpape/d/0.1/d-0.1.jar new file mode 100644 index 0000000..2ad59eb Binary files /dev/null and b/src/it/dep-reduced-pom-artifactset-provided-excludes/repo/org/apache/maven/its/shade/drpape/d/0.1/d-0.1.jar differ diff --git a/src/it/dep-reduced-pom-artifactset-provided-excludes/repo/org/apache/maven/its/shade/drpape/d/0.1/d-0.1.pom b/src/it/dep-reduced-pom-artifactset-provided-excludes/repo/org/apache/maven/its/shade/drpape/d/0.1/d-0.1.pom new file mode 100644 index 0000000..a73939d --- /dev/null +++ b/src/it/dep-reduced-pom-artifactset-provided-excludes/repo/org/apache/maven/its/shade/drpape/d/0.1/d-0.1.pom @@ -0,0 +1,48 @@ +<?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.drpape</groupId> + <artifactId>d</artifactId> + <version>0.1</version> + <packaging>jar</packaging> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + + <dependencies> + <dependency> + <groupId>org.apache.maven.its.shade.drpape</groupId> + <artifactId>e</artifactId> + <version>0.1</version> + </dependency> + </dependencies> + + <distributionManagement> + <repository> + <id>maven-core-it</id> + <url>file:///${basedir}/repo</url> + </repository> + </distributionManagement> +</project> diff --git a/src/it/dep-reduced-pom-artifactset-provided-excludes/repo/org/apache/maven/its/shade/drpape/e/0.1/e-0.1.jar b/src/it/dep-reduced-pom-artifactset-provided-excludes/repo/org/apache/maven/its/shade/drpape/e/0.1/e-0.1.jar new file mode 100644 index 0000000..1981528 Binary files /dev/null and b/src/it/dep-reduced-pom-artifactset-provided-excludes/repo/org/apache/maven/its/shade/drpape/e/0.1/e-0.1.jar differ diff --git a/src/it/dep-reduced-pom-artifactset-provided-excludes/repo/org/apache/maven/its/shade/drpape/e/0.1/e-0.1.pom b/src/it/dep-reduced-pom-artifactset-provided-excludes/repo/org/apache/maven/its/shade/drpape/e/0.1/e-0.1.pom new file mode 100644 index 0000000..6ac9a8f --- /dev/null +++ b/src/it/dep-reduced-pom-artifactset-provided-excludes/repo/org/apache/maven/its/shade/drpape/e/0.1/e-0.1.pom @@ -0,0 +1,40 @@ +<?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.drpape</groupId> + <artifactId>e</artifactId> + <version>0.1</version> + <packaging>jar</packaging> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + + <distributionManagement> + <repository> + <id>maven-core-it</id> + <url>file:///${basedir}/repo</url> + </repository> + </distributionManagement> +</project> diff --git a/src/it/dep-reduced-pom-artifactset-provided-excludes/verify.groovy b/src/it/dep-reduced-pom-artifactset-provided-excludes/verify.groovy new file mode 100644 index 0000000..06093d1 --- /dev/null +++ b/src/it/dep-reduced-pom-artifactset-provided-excludes/verify.groovy @@ -0,0 +1,40 @@ +/* + * 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 pomFile = new File( basedir, "target/dependency-reduced-pom.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() == 2 + +def depB = pom[ns.dependencies][ns.dependency][0] +assert depB[ns.artifactId].text().equals('b') +assert depB[ns.scope].text().equals('provided') +assert depB[ns.exclusions][ns.exclusion].size() == 0 + +def depD = pom[ns.dependencies][ns.dependency][1] +assert depD[ns.artifactId].text().equals('d') +assert depD[ns.scope].text().equals('provided') +def depDExclusions = depD[ns.exclusions][ns.exclusion] +assert depDExclusions.size() == 1 +assert depDExclusions[0][ns.artifactId].text().equals('e') 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 29f665c..112c301 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 @@ -1255,7 +1255,11 @@ public class ShadeMojo } } - if ( !found ) + // MSHADE-311: do not add exclusion for provided transitive dep + // note: MSHADE-31 introduced the exclusion logic for promoteTransitiveDependencies=true, + // but as of 3.2.1 promoteTransitiveDependencies has no effect for provided deps, + // which makes this fix even possible (see also MSHADE-181) + if ( !found && !"provided".equals( n3.getArtifact().getScope() ) ) { for ( Dependency dep : dependencies ) {
