This is an automated email from the ASF dual-hosted git repository. gnodet pushed a commit to branch ci-issue-12045 in repository https://gitbox.apache.org/repos/asf/maven.git
commit 52d6e484b51ae0dcf4078668ea44b1a00dd7c39f Author: Guillaume Nodet <[email protected]> AuthorDate: Wed May 13 08:14:06 2026 +0200 Fix #12045: warn when effective model analysis fails for inherited plugins Change the log level from debug to warning when effective model analysis fails in PluginUpgradeStrategy, so users are aware when plugins inherited from remote parent POMs cannot be detected for upgrade. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> --- .../invoker/mvnup/goals/PluginUpgradeStrategy.java | 2 +- .../mvnup/goals/PluginUpgradeStrategyTest.java | 40 ++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnup/goals/PluginUpgradeStrategy.java b/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnup/goals/PluginUpgradeStrategy.java index e9d145bdc5..c6c7289426 100644 --- a/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnup/goals/PluginUpgradeStrategy.java +++ b/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnup/goals/PluginUpgradeStrategy.java @@ -565,7 +565,7 @@ private Map<Path, Set<String>> analyzePluginsUsingEffectiveModels( } } catch (Exception e) { - context.debug("Failed to analyze effective model for " + originalPomPath + ": " + e.getMessage()); + context.warning("Failed to analyze effective model for " + originalPomPath + ": " + e.getMessage()); } } 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 49abdf2be5..6b4a75668c 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 @@ -38,7 +38,10 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.ArgumentMatchers.argThat; +import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; /** @@ -515,6 +518,43 @@ void shouldHaveValidPluginUpgradeDefinitions() throws Exception { @DisplayName("Error Handling") class ErrorHandlingTests { + @Test + @DisplayName("should warn when effective model analysis fails for POM with remote parent") + void shouldWarnWhenEffectiveModelAnalysisFailsForRemoteParent() throws Exception { + // POM inherits from a remote parent that cannot be resolved in test environment. + // This simulates the scenario where plugins are inherited from remote parent POMs + // (e.g., org.apache:apache:23 defining maven-enforcer-plugin:1.4.1). + // The effective model analysis should warn (not silently swallow) the failure. + 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> + <artifactId>test-child</artifactId> + </project> + """; + + Document document = Document.of(pomXml); + Map<Path, Document> pomMap = Map.of(Paths.get("pom.xml"), document); + + UpgradeContext context = createMockContext(); + UpgradeResult result = strategy.doApply(context, pomMap); + + // Strategy should complete successfully even when effective model analysis fails + assertNotNull(result, "Result should not be null"); + assertTrue(result.success(), "Strategy should succeed even when effective model analysis fails"); + assertTrue(result.processedPoms().contains(Paths.get("pom.xml")), "POM should be marked as processed"); + + // The warning should have been logged (not silently swallowed at debug level) + // Verify through the mock logger that warn was called + verify(context.logger, atLeastOnce()) + .warn(argThat(msg -> msg.contains("Failed to analyze effective model"))); + } + @Test @DisplayName("should handle malformed POM gracefully") void shouldHandleMalformedPOMGracefully() throws Exception {
