You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by gn...@apache.org on 2026/05/13 10:53:28 UTC
(maven) 01/04: Fix #12045: warn when effective model analysis fails for inherited plugins
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 c31076d8d034b5b6f50f09a8e59148d166332ddc
Author: Guillaume Nodet <gn...@gmail.com>
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) <no...@anthropic.com>
---
.../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 7e8ffc502a..82e4f4db35 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
@@ -571,7 +571,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 69cc3ec0fe..02808a77a8 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
@@ -43,7 +43,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;
/**
@@ -526,6 +529,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 {