|
55 | 55 | import org.apache.maven.wagon.observers.Debug; |
56 | 56 | import org.apache.maven.wagon.proxy.ProxyInfo; |
57 | 57 | import org.apache.maven.wagon.repository.Repository; |
| 58 | +import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration; |
| 59 | +import org.codehaus.plexus.util.xml.Xpp3Dom; |
| 60 | +import org.eclipse.aether.transport.wagon.WagonConfigurator; |
58 | 61 |
|
59 | 62 | /** |
60 | 63 | * Abstract base class for deploy mojos. |
@@ -129,6 +132,8 @@ public abstract class AbstractDeployMojo extends AbstractSiteMojo { |
129 | 132 | @Inject |
130 | 133 | SettingsDecrypter settingsDecrypter; |
131 | 134 |
|
| 135 | + @Inject |
| 136 | + private WagonConfigurator wagonConfigurator; |
132 | 137 | /** |
133 | 138 | * {@inheritDoc} |
134 | 139 | */ |
@@ -285,6 +290,28 @@ private Wagon getWagon(final Repository repository) throws MojoExecutionExceptio |
285 | 290 | throw new MojoExecutionException( |
286 | 291 | "Wagon protocol '" + repository.getProtocol() + "' doesn't support directory copying"); |
287 | 292 | } |
| 293 | + // retrieve relevant settings |
| 294 | + Server server = settings.getServer(repository.getId()); |
| 295 | + // taken over from |
| 296 | + // https://github.com/apache/maven/blob/18a52647884dcc822eb04bf5a3265a21dc83256c/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java#L242 |
| 297 | + if (server != null && server.getConfiguration() != null) { |
| 298 | + Xpp3Dom dom = (Xpp3Dom) server.getConfiguration(); |
| 299 | + for (int i = dom.getChildCount() - 1; i >= 0; i--) { |
| 300 | + Xpp3Dom child = dom.getChild(i); |
| 301 | + if ("wagonProvider".equals(child.getName())) { |
| 302 | + dom.removeChild(i); |
| 303 | + } |
| 304 | + } |
| 305 | + XmlPlexusConfiguration config = new XmlPlexusConfiguration(dom); |
| 306 | + try { |
| 307 | + // use Wagon configurator from Resolver |
| 308 | + wagonConfigurator.configure(wagon, config); |
| 309 | + } catch (Exception e) { |
| 310 | + throw new MojoExecutionException( |
| 311 | + "Error configuring wagon with server configuration for server id '" + repository.getId() + "'", |
| 312 | + e); |
| 313 | + } |
| 314 | + } |
288 | 315 | return wagon; |
289 | 316 | } |
290 | 317 |
|
|
0 commit comments