Skip to content

Commit

Permalink
- Endless processing with promoteTransitiveDependencies
Browse files Browse the repository at this point in the history
Fix the endless processing that was caused by not checking the
classifier of the dependencies when adding excludes.
  • Loading branch information
dmitri-gb authored and rfscholte committed Feb 3, 2020
1 parent 52c476a commit be330db
Show file tree
Hide file tree
Showing 11 changed files with 269 additions and 6 deletions.
18 changes: 18 additions & 0 deletions src/it/dep-reduced-pom-exclusions/invoker.properties
Original file line number Diff line number Diff line change
@@ -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.timeoutInSeconds=60
90 changes: 90 additions & 0 deletions src/it/dep-reduced-pom-exclusions/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?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.drpe</groupId>
<artifactId>test</artifactId>
<version>1.0</version>
<packaging>jar</packaging>

<name>MSHADE-223</name>
<description>
Test that creation of the dependency reduced POM properly handles dependencies with classifiers.
</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.drpe</groupId>
<artifactId>a</artifactId>
<version>0.1</version>
<exclusions>
<exclusion>
<groupId>org.apache.maven.its.shade.drpe</groupId>
<artifactId>c</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>
<promoteTransitiveDependencies>true</promoteTransitiveDependencies>
<shadedArtifactAttached>false</shadedArtifactAttached>
<createDependencyReducedPom>true</createDependencyReducedPom>
<artifactSet>
<includes>
<include>org.apache.maven.its.shade.drpe:a</include>
</includes>
</artifactSet>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?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.drpe</groupId>
<artifactId>a</artifactId>
<version>0.1</version>
<packaging>jar</packaging>

<distributionManagement>
<repository>
<id>maven-core-it</id>
<url>file:///${basedir}/repo</url>
</repository>
</distributionManagement>

<dependencies>
<dependency>
<groupId>org.apache.maven.its.shade.drpe</groupId>
<artifactId>b</artifactId>
<version>0.2</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its.shade.drpe</groupId>
<artifactId>b</artifactId>
<classifier>alt</classifier>
<version>0.2</version>
</dependency>
</dependencies>
</project>
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?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.drpe</groupId>
<artifactId>b</artifactId>
<version>0.2</version>
<packaging>jar</packaging>

<distributionManagement>
<repository>
<id>maven-core-it</id>
<url>file:///${basedir}/repo</url>
</repository>
</distributionManagement>

<dependencies>
<dependency>
<groupId>org.apache.maven.its.shade.drpe</groupId>
<artifactId>c</artifactId>
<version>1</version>
</dependency>
</dependencies>
</project>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?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.drpe</groupId>
<artifactId>c</artifactId>
<version>1</version>
<packaging>jar</packaging>

<distributionManagement>
<repository>
<id>maven-core-it</id>
<url>file:///${basedir}/repo</url>
</repository>
</distributionManagement>
</project>
29 changes: 29 additions & 0 deletions src/it/dep-reduced-pom-exclusions/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* 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, "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
assert pom[ns.dependencies][ns.dependency][0][ns.exclusions][ns.exclusion].size() == 1
assert pom[ns.dependencies][ns.dependency][1][ns.exclusions][ns.exclusion].size() == 1
Original file line number Diff line number Diff line change
Expand Up @@ -1252,9 +1252,7 @@ public boolean updateExcludesInDeps( MavenProject project, List<Dependency> depe
boolean found = false;
for ( Dependency dep : transitiveDeps )
{
if ( dep.getArtifactId().equals( n3.getArtifact().getArtifactId() ) //
&& dep.getGroupId().equals( n3.getArtifact().getGroupId() ) //
&& ( dep.getType() == null || dep.getType().equals( n3.getArtifact().getType() ) ) )
if ( getId( dep ).equals( getId( n3.getArtifact() ) ) )
{
found = true;
break;
Expand All @@ -1269,9 +1267,7 @@ public boolean updateExcludesInDeps( MavenProject project, List<Dependency> depe
{
for ( Dependency dep : dependencies )
{
if ( dep.getArtifactId().equals( n2.getArtifact().getArtifactId() ) //
&& dep.getGroupId().equals( n2.getArtifact().getGroupId() ) //
&& ( dep.getType() == null || dep.getType().equals( n2.getArtifact().getType() ) ) )
if ( getId( dep ).equals( getId( n2.getArtifact() ) ) )
{
Exclusion exclusion = new Exclusion();
exclusion.setArtifactId( n3.getArtifact().getArtifactId() );
Expand Down

0 comments on commit be330db

Please sign in to comment.