Description
When using flatten-maven-plugin with updatePomFile=true and <parent>expand</parent>, Maven incorrectly detects a parent cycle during the install phase.
Error Message
Failed to execute goal org.apache.maven.plugins:maven-install-plugin:3.1.4:install (default-install) on project: Execution default-install of goal org.apache.maven.plugins:maven-install-plugin:3.1.4:install failed: org.apache.maven.api.services.ModelBuilderException: 1 problem was encountered while building the effective model
[FATAL] The parents form a cycle: org.apache:apache:35 -> /path/to/pom.xml -> org.apache:apache:35
Reproduction
Create a POM with:
- A parent reference (e.g.,
org.apache:apache:35)
flatten-maven-plugin configured with:
updatePomFile=true
<parent>expand</parent>
Run mvn install and the build fails with the cycle detection error.
Root Cause
The consumer POM builder was using Path instead of ModelSource when reading the flattened POM. This caused the cycle detector to incorrectly identify a cycle because it couldn't properly resolve the parent relationship context.
Solution
Change the PomArtifactTransformer API to use ModelSource instead of Path. The ModelSource includes the necessary context (base directory, ModelLocator) to properly resolve parent POMs and avoid false cycle detection.
Maven Version
Maven 4.0.x
Description
When using
flatten-maven-pluginwithupdatePomFile=trueand<parent>expand</parent>, Maven incorrectly detects a parent cycle during the install phase.Error Message
Reproduction
Create a POM with:
org.apache:apache:35)flatten-maven-pluginconfigured with:updatePomFile=true<parent>expand</parent>Run
mvn installand the build fails with the cycle detection error.Root Cause
The consumer POM builder was using
Pathinstead ofModelSourcewhen reading the flattened POM. This caused the cycle detector to incorrectly identify a cycle because it couldn't properly resolve the parent relationship context.Solution
Change the
PomArtifactTransformerAPI to useModelSourceinstead ofPath. TheModelSourceincludes the necessary context (base directory, ModelLocator) to properly resolve parent POMs and avoid false cycle detection.Maven Version
Maven 4.0.x