False parent cycle detection with flatten-maven-plugin updatePomFile (original) (raw)

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:

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