Skip to content

Conversation

@gnodet
Copy link
Contributor

@gnodet gnodet commented Nov 6, 2025

Description

Fixes #11399

When using flatten-maven-plugin with updatePomFile=true and <parent>expand</parent>, Maven incorrectly detected a parent cycle during the install phase. The error occurred because the consumer POM builder was using Path instead of ModelSource when reading the flattened POM.

Changes

  • Updated PomArtifactTransformer.transform() to accept ModelSource instead of Path
  • Modified ConsumerPomArtifactTransformer to create ModelSource with proper resolution context (base directory, ModelLocator)
  • Updated DefaultConsumerPomBuilder and related classes to work with ModelSource
  • Added integration test MavenITgh11399FlattenPluginParentCycleTest to verify the fix

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

ModelSource includes the necessary context (base directory, ModelLocator) to properly resolve parent POMs and avoid false cycle detection. By providing a ModelSource with a proper resolve() implementation, the parent POM can be correctly located and the cycle detection works as expected.

Testing

  • Added integration test that reproduces the issue and verifies the fix
  • Full build passes: mvn install -DskipTests
  • Integration test passes: mvn test -Prun-its -Dtest=MavenITgh11399*

Pull Request opened by Augment Code with guidance from the PR author

@gnodet gnodet changed the title [GH-11399] Fix false parent cycle detection with flatten-maven-plugin Fix false parent cycle detection with flatten-maven-plugin Nov 6, 2025
@gnodet gnodet changed the base branch from master to maven-4.0.x November 6, 2025 07:30
@gnodet gnodet added bug Something isn't working mvn40 labels Nov 6, 2025
…che#11399)

When using flatten-maven-plugin with updatePomFile=true and parent expansion,
Maven incorrectly detected a parent cycle during the install phase. The error
occurred because the consumer POM builder was using Path instead of ModelSource
when reading the flattened POM.

This change updates the PomArtifactTransformer API to use ModelSource instead
of Path. ModelSource includes the necessary context (base directory, ModelLocator)
to properly resolve parent POMs and avoid false cycle detection.

Changes:
- Updated PomArtifactTransformer.transform() to accept ModelSource instead of Path
- Modified ConsumerPomArtifactTransformer to create ModelSource with proper resolution context
- Updated DefaultConsumerPomBuilder and related classes to work with ModelSource
- Added integration test to verify the fix

Fixes apache#11399
@gnodet gnodet merged commit 5ec059c into apache:maven-4.0.x Nov 6, 2025
22 checks passed
@github-actions github-actions bot added this to the 4.0.0 milestone Nov 6, 2025
gnodet added a commit to gnodet/maven that referenced this pull request Nov 6, 2025
…che#11399) (apache#11400)

When using flatten-maven-plugin with updatePomFile=true and parent expansion,
Maven incorrectly detected a parent cycle during the install phase. The error
occurred because the consumer POM builder was using Path instead of ModelSource
when reading the flattened POM.

This change updates the PomArtifactTransformer API to use ModelSource instead
of Path. ModelSource includes the necessary context (base directory, ModelLocator)
to properly resolve parent POMs and avoid false cycle detection.

Changes:
- Updated PomArtifactTransformer.transform() to accept ModelSource instead of Path
- Modified ConsumerPomArtifactTransformer to create ModelSource with proper resolution context
- Updated DefaultConsumerPomBuilder and related classes to work with ModelSource
- Added integration test to verify the fix

Fixes apache#11399

(cherry picked from commit 5ec059c)

# Conflicts:
#	impl/maven-core/src/test/java/org/apache/maven/internal/transformation/impl/ConsumerPomArtifactTransformerTest.java
@gnodet
Copy link
Contributor Author

gnodet commented Nov 6, 2025

💚 All backports created successfully

Status Branch Result
master

Questions ?

Please refer to the Backport tool documentation

gnodet added a commit that referenced this pull request Nov 6, 2025
) (#11400) (#11403)

When using flatten-maven-plugin with updatePomFile=true and parent expansion,
Maven incorrectly detected a parent cycle during the install phase. The error
occurred because the consumer POM builder was using Path instead of ModelSource
when reading the flattened POM.

This change updates the PomArtifactTransformer API to use ModelSource instead
of Path. ModelSource includes the necessary context (base directory, ModelLocator)
to properly resolve parent POMs and avoid false cycle detection.

Changes:
- Updated PomArtifactTransformer.transform() to accept ModelSource instead of Path
- Modified ConsumerPomArtifactTransformer to create ModelSource with proper resolution context
- Updated DefaultConsumerPomBuilder and related classes to work with ModelSource
- Added integration test to verify the fix

Fixes #11399

(cherry picked from commit 5ec059c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working mvn40

Projects

None yet

Development

Successfully merging this pull request may close these issues.

False parent cycle detection with flatten-maven-plugin updatePomFile

2 participants