[ https://issues.apache.org/jira/browse/MSHADE-399?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Stefan Filip updated MSHADE-399: -------------------------------- Description: Hello, The Maven Shade plugin goes into an infinite loop when we specify a test dependency with the following properties: # the artifactId of the dependency is specified using properties (requires interpolation) # we have a parent that specified a different version of the dependency # the test dependency has dependencies of its own I attached the smallest repro that I could get in mvn-cycle.zip. `mvn clean install` will reproduce the issue. I debugged a bit but I don't understand exactly what the code is trying to do or the maven APIs that are called. The issue here looks to be that the project that is constructed at the reduced-pom phase. The reduced project ends up using a different dependency than the one the real project. Exclusions keeps getting added to this different dependency indefinitely. Let me know if you have questions. — Repro: - pom.xml: {code:java} <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>org.example.test</groupId> <artifactId>parent</artifactId> <version>1.0.0-SNAPSHOT</version> <packaging>pom</packaging> <modules> <module>alpha</module> </modules> <properties> <scala.binary.version>2.12</scala.binary.version> </properties> <dependencies> <dependency> <groupId>org.scalatest</groupId> <artifactId>scalatest_${scala.binary.version}</artifactId> <version>3.0.3</version> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>3.3.1-SNAPSHOT</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </project> {code} - alpha/pom.xml: {code:java} <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.example.test</groupId> <artifactId>parent</artifactId> <version>1.0.0-SNAPSHOT</version> <relativePath>../pom.xml</relativePath> </parent> <groupId>org.example.test</groupId> <artifactId>alpha</artifactId> <packaging>jar</packaging> <dependencies> <dependency> <groupId>org.scala-lang</groupId> <artifactId>scala-library</artifactId> <version>2.11.12</version> </dependency> <dependency> <groupId>org.scalatest</groupId> <artifactId>scalatest_${scala.binary.version}</artifactId> <version>3.0.0</version> <scope>test</scope> </dependency> </dependencies> </project> {code} was: Hello, The Maven Shade plugin goes into an infinite loop when we specify a test dependency with the following properties: # the artifactId of the dependency is specified using properties (requires interpolation) # we have a parent that specified a different version of the dependency # the test dependency has dependencies of its own I attached the smallest repro that I could get in mvn-cycle.zip. `mvn clean install` will reproduce the issue. I debugged a bit but I don't understand exactly what the code is trying to do or the maven APIs that are called. The issue here looks to be that the project that is constructed at the reduced-pom phase. The project ends up having a the dependency list that contains both versions of test dependency and that invalidates the assumptions of the reduction loop. Let me know if you have questions. — Repro: - pom.xml: {code:java} <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>org.example.test</groupId> <artifactId>parent</artifactId> <version>1.0.0-SNAPSHOT</version> <packaging>pom</packaging> <modules> <module>alpha</module> </modules> <properties> <scala.binary.version>2.12</scala.binary.version> </properties> <dependencies> <dependency> <groupId>org.scalatest</groupId> <artifactId>scalatest_${scala.binary.version}</artifactId> <version>3.0.3</version> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>3.3.1-SNAPSHOT</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </project> {code} - alpha/pom.xml: {code:java} <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.example.test</groupId> <artifactId>parent</artifactId> <version>1.0.0-SNAPSHOT</version> <relativePath>../pom.xml</relativePath> </parent> <groupId>org.example.test</groupId> <artifactId>alpha</artifactId> <packaging>jar</packaging> <dependencies> <dependency> <groupId>org.scala-lang</groupId> <artifactId>scala-library</artifactId> <version>2.11.12</version> </dependency> <dependency> <groupId>org.scalatest</groupId> <artifactId>scalatest_${scala.binary.version}</artifactId> <version>3.0.0</version> <scope>test</scope> </dependency> </dependencies> </project> {code} > Infinite cycle with test dependency at different versions > --------------------------------------------------------- > > Key: MSHADE-399 > URL: https://issues.apache.org/jira/browse/MSHADE-399 > Project: Maven Shade Plugin > Issue Type: Bug > Affects Versions: 3.2.4 > Environment: maven 3.8.1 > maven-shade-plugin 3.3.1-SNAPSHOT (I tested various version, 2.4.1, 3.1.1, > 3.2.1, 3.2.4) > jdk 1.8 > macos 11.4 / linux 5.2.9 > Reporter: Stefan Filip > Priority: Major > Attachments: alpha-pom.xml, mvn-cycle.zip, pom.xml > > > Hello, > The Maven Shade plugin goes into an infinite loop when we specify a test > dependency with the following properties: > # the artifactId of the dependency is specified using properties (requires > interpolation) > # we have a parent that specified a different version of the dependency > # the test dependency has dependencies of its own > I attached the smallest repro that I could get in mvn-cycle.zip. `mvn clean > install` will reproduce the issue. > I debugged a bit but I don't understand exactly what the code is trying to do > or the maven APIs that are called. The issue here looks to be that the > project that is constructed at the reduced-pom phase. The reduced project > ends up using a different dependency than the one the real project. > Exclusions keeps getting added to this different dependency indefinitely. > Let me know if you have questions. > — > Repro: > - pom.xml: > {code:java} > <?xml version="1.0" encoding="UTF-8"?> > <project xmlns="http://maven.apache.org/POM/4.0.0" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 > http://maven.apache.org/xsd/maven-4.0.0.xsd"> > <modelVersion>4.0.0</modelVersion> <groupId>org.example.test</groupId> > <artifactId>parent</artifactId> > <version>1.0.0-SNAPSHOT</version> > <packaging>pom</packaging> > <modules> > <module>alpha</module> > </modules> > <properties> > <scala.binary.version>2.12</scala.binary.version> > </properties> > <dependencies> > <dependency> > <groupId>org.scalatest</groupId> > <artifactId>scalatest_${scala.binary.version}</artifactId> > <version>3.0.3</version> > <scope>test</scope> > </dependency> > </dependencies> > <build> > <plugins> > <plugin> > <groupId>org.apache.maven.plugins</groupId> > <artifactId>maven-shade-plugin</artifactId> > <version>3.3.1-SNAPSHOT</version> > <executions> > <execution> > <phase>package</phase> > <goals> > <goal>shade</goal> > </goals> > </execution> > </executions> > </plugin> > </plugins> > </build> > </project> > {code} > - alpha/pom.xml: > {code:java} > <?xml version="1.0" encoding="UTF-8"?> > <project xmlns="http://maven.apache.org/POM/4.0.0" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 > http://maven.apache.org/xsd/maven-4.0.0.xsd"> > <modelVersion>4.0.0</modelVersion> > <parent> > <groupId>org.example.test</groupId> > <artifactId>parent</artifactId> > <version>1.0.0-SNAPSHOT</version> > <relativePath>../pom.xml</relativePath> > </parent> > <groupId>org.example.test</groupId> > <artifactId>alpha</artifactId> > <packaging>jar</packaging> > <dependencies> > <dependency> > <groupId>org.scala-lang</groupId> > <artifactId>scala-library</artifactId> > <version>2.11.12</version> > </dependency> > <dependency> > <groupId>org.scalatest</groupId> > <artifactId>scalatest_${scala.binary.version}</artifactId> > <version>3.0.0</version> > <scope>test</scope> > </dependency> > </dependencies> > </project> {code} -- This message was sent by Atlassian Jira (v8.3.4#803005)