This is an automated email from the ASF dual-hosted git repository.

kwin pushed a commit to branch bugfix/configure-wagon
in repository https://gitbox.apache.org/repos/asf/maven-site-plugin.git

commit e8bef61ea2d46b1fe6a2d5f67169293da89512c6
Author: Konrad Windszus <[email protected]>
AuthorDate: Sat Feb 21 13:55:36 2026 +0100

    Configure Wagon from settings.xml
    
    This regressed with
    
https://github.com/apache/maven-site-plugin/commit/e414d23496e5bd3949774f2f8267e93eebf69f10
    
    This closes #1217
---
 pom.xml                                            |  7 ++++++
 .../plugins/site/deploy/AbstractDeployMojo.java    | 26 ++++++++++++++++++++++
 2 files changed, 33 insertions(+)

diff --git a/pom.xml b/pom.xml
index 8b8f5218..3df93942 100644
--- a/pom.xml
+++ b/pom.xml
@@ -284,6 +284,13 @@ under the License.
       <version>${mavenVersion}</version>
       <scope>provided</scope>
     </dependency>
+    <!-- reusing component to configure Wagon -->
+    <dependency>
+      <groupId>org.apache.maven.resolver</groupId>
+      <artifactId>maven-resolver-transport-wagon</artifactId>
+      <version>1.4.1</version><!-- version shipping with Maven 3.6.3-->
+      <scope>compile</scope>
+    </dependency>
 
     <dependency>
       <groupId>org.apache.maven</groupId>
diff --git 
a/src/main/java/org/apache/maven/plugins/site/deploy/AbstractDeployMojo.java 
b/src/main/java/org/apache/maven/plugins/site/deploy/AbstractDeployMojo.java
index 7419cb01..d76a69b0 100644
--- a/src/main/java/org/apache/maven/plugins/site/deploy/AbstractDeployMojo.java
+++ b/src/main/java/org/apache/maven/plugins/site/deploy/AbstractDeployMojo.java
@@ -55,6 +55,9 @@ import 
org.apache.maven.wagon.authorization.AuthorizationException;
 import org.apache.maven.wagon.observers.Debug;
 import org.apache.maven.wagon.proxy.ProxyInfo;
 import org.apache.maven.wagon.repository.Repository;
+import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
+import org.eclipse.aether.transport.wagon.WagonConfigurator;
 
 /**
  * Abstract base class for deploy mojos.
@@ -129,6 +132,8 @@ public abstract class AbstractDeployMojo extends 
AbstractSiteMojo {
     @Inject
     SettingsDecrypter settingsDecrypter;
 
+    @Inject
+    private WagonConfigurator wagonConfigurator;
     /**
      * {@inheritDoc}
      */
@@ -285,9 +290,30 @@ public abstract class AbstractDeployMojo extends 
AbstractSiteMojo {
             throw new MojoExecutionException(
                     "Wagon protocol '" + repository.getProtocol() + "' doesn't 
support directory copying");
         }
+        // retrieve relevant settings
+        Server server = settings.getServer(repository.getId());
+        // taken over from 
https://github.com/apache/maven/blob/18a52647884dcc822eb04bf5a3265a21dc83256c/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java#L242
+        if (server != null && server.getConfiguration() != null) {
+            Xpp3Dom dom = (Xpp3Dom) server.getConfiguration();
+            for (int i = dom.getChildCount() - 1; i >= 0; i--) {
+                Xpp3Dom child = dom.getChild(i);
+                if ("wagonProvider".equals(child.getName())) {
+                    dom.removeChild(i);
+                }
+            }
+            XmlPlexusConfiguration config = new XmlPlexusConfiguration(dom);
+            try {
+                // use Wagon configurator from Resolver
+                wagonConfigurator.configure(wagon, config);
+            } catch (Exception e) {
+                throw new MojoExecutionException("Error configuring wagon with 
server configuration for server id '" + repository.getId()
+                        + "'", e);
+            }
+        }
         return wagon;
     }
 
+    
     public AuthenticationInfo getAuthenticationInfo(String id) {
         if (id != null) {
             List<Server> servers = settings.getServers();

Reply via email to