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 1f1564928cb16da4d9078fbf74645c380c3fbc4b
Author: Guillaume Nodet <[email protected]>
AuthorDate: Wed May 13 09:01:30 2026 +0200

    Fix standalone session transport for effective model resolution
    
    Register transporter factories via @Provides methods so they properly
    feed into the DI Map<String, TransporterFactory>, fixing the standalone
    session's ability to resolve remote parent POMs from Maven Central.
    
    The previous approach of binding TransporterProvider directly was
    overridden by the @Provides method in RepositorySystemSupplier which
    received an empty factory map, leaving no HTTP transport available.
    
    Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
---
 .../invoker/mvnup/goals/PluginUpgradeStrategy.java | 38 ++++++++++++++--------
 .../mvnup/goals/PluginUpgradeStrategyTest.java     | 15 ++++-----
 2 files changed, 31 insertions(+), 22 deletions(-)

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 82e4f4db35..3b0dfa6538 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
@@ -35,6 +35,7 @@
 import org.apache.maven.api.di.Inject;
 import org.apache.maven.api.di.Named;
 import org.apache.maven.api.di.Priority;
+import org.apache.maven.api.di.Provides;
 import org.apache.maven.api.di.Singleton;
 import org.apache.maven.api.model.Build;
 import org.apache.maven.api.model.Model;
@@ -52,10 +53,9 @@
 import org.apache.maven.impl.standalone.ApiRunner;
 import org.codehaus.plexus.components.secdispatcher.Dispatcher;
 import 
org.codehaus.plexus.components.secdispatcher.internal.dispatchers.LegacyDispatcher;
-import org.eclipse.aether.internal.impl.DefaultPathProcessor;
-import org.eclipse.aether.internal.impl.DefaultTransporterProvider;
-import 
org.eclipse.aether.internal.impl.transport.http.DefaultChecksumExtractor;
-import org.eclipse.aether.spi.connector.transport.TransporterProvider;
+import org.eclipse.aether.spi.connector.transport.TransporterFactory;
+import org.eclipse.aether.spi.connector.transport.http.ChecksumExtractor;
+import org.eclipse.aether.spi.io.PathProcessor;
 import org.eclipse.aether.transport.file.FileTransporterFactory;
 import org.eclipse.aether.transport.jdk.JdkTransporterFactory;
 import org.jdom2.Document;
@@ -441,15 +441,7 @@ private Session getSession() {
     private Session createMaven4Session() {
         Session session = ApiRunner.createSession(injector -> {
             injector.bindInstance(Dispatcher.class, new LegacyDispatcher());
-
-            injector.bindInstance(
-                    TransporterProvider.class,
-                    new DefaultTransporterProvider(Map.of(
-                            "https",
-                            new JdkTransporterFactory(
-                                    new DefaultChecksumExtractor(Map.of()), 
new DefaultPathProcessor()),
-                            "file",
-                            new FileTransporterFactory())));
+            injector.bindImplicit(TransporterFactoryConfig.class);
         });
 
         // Configure repositories
@@ -897,4 +889,24 @@ public static class PluginUpgradeInfo {
             this.minVersion = minVersion;
         }
     }
+
+    /**
+     * DI configuration that registers transporter factories for the 
standalone Maven session.
+     * Uses {@code @Provides} methods so the factories are properly registered 
as named beans
+     * and feed into the {@code Map<String, TransporterFactory>} used by the 
TransporterProvider.
+     */
+    static class TransporterFactoryConfig {
+        @Provides
+        @Named(JdkTransporterFactory.NAME)
+        static TransporterFactory jdkTransporterFactory(
+                ChecksumExtractor checksumExtractor, PathProcessor 
pathProcessor) {
+            return new JdkTransporterFactory(checksumExtractor, pathProcessor);
+        }
+
+        @Provides
+        @Named(FileTransporterFactory.NAME)
+        static TransporterFactory fileTransporterFactory() {
+            return new FileTransporterFactory();
+        }
+    }
 }
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 02808a77a8..13c400c6bf 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
@@ -530,20 +530,18 @@ void shouldHaveValidPluginUpgradeDefinitions() throws 
Exception {
     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).
+        @DisplayName("should warn when effective model analysis fails for POM 
with unresolvable remote parent")
+        void 
shouldWarnWhenEffectiveModelAnalysisFailsForUnresolvableRemoteParent() throws 
Exception {
+            // POM inherits from a remote parent that does not exist.
             // 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>
+                        <groupId>com.nonexistent.test</groupId>
+                        <artifactId>nonexistent-parent</artifactId>
+                        <version>1.0.0</version>
                     </parent>
                     <artifactId>test-child</artifactId>
                 </project>
@@ -561,7 +559,6 @@ void 
shouldWarnWhenEffectiveModelAnalysisFailsForRemoteParent() throws Exception
             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")));
         }

Reply via email to