apache / apache/maven-shade-plugin
[MSHADE-399] Infinite cycle with test dependency at different versions
- Dominant language
- Java
- Stars
- 188
- Forks
- 103
- Avg merge
- 16h 39m
- Merged PRs (30d)
- 4
Description
**[Stefan Filip](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=sfilip)** opened **[MSHADE-399](https://issues.apache.org/jira/browse/MSHADE-399?redirect=false)** and commented
Hello,
The Maven Shade plugin goes into an infinite loop when we specify a test dependency with the following properties:
1. the artifactId of the dependency is specified using properties (requires interpolation)
2. we have a parent that specified a different version of the dependency
3. 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:
```java
4.0.0 org.example.test
parent
1.0.0-SNAPSHOT
pom
alpha
2.12
org.scalatest
scalatest_${scala.binary.version}
3.0.3
test
org.apache.maven.plugins
maven-shade-plugin
3.3.1-SNAPSHOT
package
shade
```
- alpha/pom.xml:
```java
4.0.0
org.example.test
parent
1.0.0-SNAPSHOT
../pom.xml
org.example.test
alpha
jar
org.scala-lang
scala-library
2.11.12
org.scalatest
scalatest_${scala.binary.version}
3.0.0
test
```
---
**Affects:** 3.2.4
**Attachments:**
- [alpha-pom.xml](https://issues.apache.org/jira/secure/attachment/13030853/alpha-pom.xml) (_964 bytes_)
- [mvn-cycle.zip](https://issues.apache.org/jira/secure/attachment/13030847/mvn-cycle.zip) (_1.61 kB_)
- [pom.xml](https://issues.apache.org/jira/secure/attachment/13030852/pom.xml) (_1.33 kB_)
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the attached pom.xml and alpha/pom.xml, then run `mvn clean install` to reproduce the infinite loop. Trace the reduced-pom phase and the exclusion handling around the dependency with the interpolated artifactId and differing versions. Done means this reproduction completes without endlessly adding exclusions or resolving the wrong dependency.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100