Skip to content

False parent cycle detection with flatten-maven-plugin updatePomFile #11399

@gnodet

Description

@gnodet

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions