This is an automated email from the ASF dual-hosted git repository. gnodet pushed a commit to branch maven-4.0.x-test-fixes in repository https://gitbox.apache.org/repos/asf/maven.git
commit 2f8b2329d549b52899720575546584b8ed3e4c30 Author: Guillaume Nodet <[email protected]> AuthorDate: Wed May 13 09:33:44 2026 +0200 Add test for inherited plugin detection from remote parent POM Verifies that the standalone session can resolve org.apache:apache:23 from Maven Central and detect maven-enforcer-plugin:1.4.1 in the parent's pluginManagement as needing a Maven 4 compatibility upgrade. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> --- .../mvnup/goals/PluginUpgradeStrategyTest.java | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvnup/goals/PluginUpgradeStrategyTest.java b/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvnup/goals/PluginUpgradeStrategyTest.java index 13c400c6bf..236347c9c3 100644 --- a/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvnup/goals/PluginUpgradeStrategyTest.java +++ b/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvnup/goals/PluginUpgradeStrategyTest.java @@ -525,6 +525,50 @@ void shouldHaveValidPluginUpgradeDefinitions() throws Exception { } } + @Nested + @DisplayName("Inherited Plugin Detection") + class InheritedPluginDetectionTests { + + @Test + @DisplayName("should detect inherited plugins from remote parent POM and add pluginManagement") + void shouldDetectInheritedPluginsFromRemoteParent() throws Exception { + // org.apache:apache:23 defines maven-enforcer-plugin:1.4.1 in pluginManagement. + // A child POM that inherits from this parent should get pluginManagement overrides + // added by mvnup for plugins that need Maven 4 compatibility upgrades. + // Uses an absolute path because the effective model analysis path resolution + // requires it to match between phases. + String pomXml = """ + <?xml version="1.0" encoding="UTF-8"?> + <project xmlns="http://maven.apache.org/POM/4.0.0"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache</groupId> + <artifactId>apache</artifactId> + <version>23</version> + </parent> + <groupId>org.example</groupId> + <artifactId>test-child</artifactId> + <version>1.0.0-SNAPSHOT</version> + </project> + """; + + Document document = Document.of(pomXml); + Path pomPath = Paths.get("/project/pom.xml").toAbsolutePath(); + Map<Path, Document> pomMap = Map.of(pomPath, document); + + UpgradeContext context = createMockContext(); + UpgradeResult result = strategy.doApply(context, pomMap); + + assertTrue(result.success(), "Strategy should succeed"); + assertTrue(result.modifiedCount() > 0, "Should have added plugin management for inherited plugins"); + + String xml = DomUtils.toXml(document); + assertTrue( + xml.contains("<artifactId>maven-enforcer-plugin</artifactId>"), + "Should add pluginManagement for maven-enforcer-plugin inherited from parent"); + } + } + @Nested @DisplayName("Error Handling") class ErrorHandlingTests {
