Summary
The dependency-reduced-pom.xml generated by the shade plugin preserves the original POM's <parent> element without setting an explicit <relativePath/>. In Maven 4, this can cause a false parent cycle detection error when the default relative path .. resolves to a POM with a different GA that shares the same parent reference.
Reproduction
Build any project using the shade plugin with a parent POM, e.g., apache/maven-doxia-converter:
With Maven 4, this fails with:
[FATAL] The parents form a cycle: org.apache.maven.doxia:doxia-tools:43 ->
/path/to/project/pom.xml -> org.apache.maven.doxia:doxia-tools:43
for project [inherited]:doxia-converter:jar:1.4-SNAPSHOT
at /path/to/project/dependency-reduced-pom.xml
Root cause
The generated dependency-reduced-pom.xml inherits the parent element as-is from the original POM. Since no <relativePath/> is set, Maven defaults to .., which may resolve to a POM that is not the actual parent. Maven 4's stricter model builder detects this as a cycle when the resolved POM shares the same parent reference.
Proposed fix
When writing the dependency-reduced-pom.xml, set <relativePath/> (empty) in the parent element to explicitly disable local parent resolution. The parent should always be resolved from the repository for generated POMs.
Workaround
A fix has been submitted for the Maven 4 model builder (apache/maven#12078, apache/maven#12079) that detects the GA mismatch early and avoids the false cycle. However, setting <relativePath/> in the generated POM is the correct long-term fix on the plugin side.
Environment
- Maven: 4.0.0-rc-2+
- maven-shade-plugin: 3.6.0 / 3.6.1
Related: apache/maven#12074
Claude Code on behalf of Guillaume Nodet
Summary
The
dependency-reduced-pom.xmlgenerated by the shade plugin preserves the original POM's<parent>element without setting an explicit<relativePath/>. In Maven 4, this can cause a false parent cycle detection error when the default relative path..resolves to a POM with a different GA that shares the same parent reference.Reproduction
Build any project using the shade plugin with a parent POM, e.g., apache/maven-doxia-converter:
With Maven 4, this fails with:
Root cause
The generated
dependency-reduced-pom.xmlinherits the parent element as-is from the original POM. Since no<relativePath/>is set, Maven defaults to.., which may resolve to a POM that is not the actual parent. Maven 4's stricter model builder detects this as a cycle when the resolved POM shares the same parent reference.Proposed fix
When writing the
dependency-reduced-pom.xml, set<relativePath/>(empty) in the parent element to explicitly disable local parent resolution. The parent should always be resolved from the repository for generated POMs.Workaround
A fix has been submitted for the Maven 4 model builder (apache/maven#12078, apache/maven#12079) that detects the GA mismatch early and avoids the false cycle. However, setting
<relativePath/>in the generated POM is the correct long-term fix on the plugin side.Environment
Related: apache/maven#12074
Claude Code on behalf of Guillaume Nodet