diff --git a/maven-resolver-transport-http/src/main/java/org/eclipse/aether/transport/http/HttpTransporter.java b/maven-resolver-transport-http/src/main/java/org/eclipse/aether/transport/http/HttpTransporter.java index 097686175..0df3c3ab5 100644 --- a/maven-resolver-transport-http/src/main/java/org/eclipse/aether/transport/http/HttpTransporter.java +++ b/maven-resolver-transport-http/src/main/java/org/eclipse/aether/transport/http/HttpTransporter.java @@ -102,6 +102,7 @@ final class HttpTransporter extends AbstractTransporter { static final String BIND_ADDRESS = "aether.connector.bind.address"; + static final String SUPPORT_WEBDAV = "aether.connector.http.supportWebDav"; static final String PREEMPTIVE_PUT_AUTH = "aether.connector.http.preemptivePutAuth"; @@ -255,7 +256,7 @@ final class HttpTransporter extends AbstractTransporter { RequestConfig requestConfig = RequestConfig.custom() .setConnectTimeout(connectTimeout) .setConnectionRequestTimeout(connectTimeout) - .setLocalAddress(getBindAddress(session)) + .setLocalAddress(getBindAddress(session, repository)) .setSocketTimeout(requestTimeout) .build(); @@ -300,17 +301,24 @@ final class HttpTransporter extends AbstractTransporter { this.client = builder.build(); } - private InetAddress getBindAddress(RepositorySystemSession session) { - String bindAddress = ConfigUtils.getString(session, null, BIND_ADDRESS); - return Optional.ofNullable(bindAddress).map(this::resolveAddress).orElse(null); - } - - private InetAddress resolveAddress(String bindAddress) { - try { - return InetAddress.getByName(bindAddress); - } catch (UnknownHostException uhe) { - throw new IllegalArgumentException("Given bind address (" + bindAddress + ") cannot be resolved.", uhe); - } + /** + * Returns non-null {@link InetAddress} if set in configuration, {@code null} otherwise. + */ + private InetAddress getBindAddress(RepositorySystemSession session, RemoteRepository repository) { + String bindAddress = + ConfigUtils.getString(session, null, BIND_ADDRESS + "." + repository.getId(), BIND_ADDRESS); + return Optional.ofNullable(bindAddress) + .map(a -> { + try { + return InetAddress.getByName(bindAddress); + } catch (UnknownHostException uhe) { + throw new IllegalArgumentException( + "Given bind address (" + bindAddress + ") cannot be resolved for remote repository " + + repository, + uhe); + } + }) + .orElse(null); } private static HttpHost toHost(Proxy proxy) { diff --git a/src/site/markdown/configuration.md b/src/site/markdown/configuration.md index 357586739..5d1df32e1 100644 --- a/src/site/markdown/configuration.md +++ b/src/site/markdown/configuration.md @@ -34,7 +34,7 @@ Option | Type | Description | Default Value | Supports Repo ID Suffix `aether.connector.basic.parallelPut` | boolean | Enables or disables parallel PUT processing (parallel deploys) on basic connector globally or per remote repository. When disabled, connector behaves exactly as in Maven 3.8.x did: GETs are parallel while PUTs are sequential. | `true` | yes `aether.connector.classpath.loader` | ClassLoader | `ClassLoader` from which resources should be retrieved which start with the `classpath:` protocol. | `Thread.currentThread().getContextClassLoader()` | no `aether.connector.connectTimeout` | long | Connect timeout in milliseconds. | `10000` | yes -`aether.connector.http.bind.address` | String | Set the outgoing interface. Valid values are local accessible IP addresses or host names. The default will use the system's default route. Invalid addresses will result in a failing build. | `null` | no +`aether.connector.http.bind.address` | String | Set the outgoing interface (globally or per remote repository). Valid values are local accessible IP addresses or host names. The default will use the system's default route. Invalid addresses will result in a failing build. | `null` | yes `aether.connector.http.cacheState` | boolean | Flag indicating whether a memory-based cache is used for user tokens, connection managers, expect continue requests and authentication schemes. | `true` | no `aether.connector.http.connectionMaxTtl` | int | Time to live in seconds for an HTTP connection, after that time, the connection will be dropped. | `600` | yes `aether.connector.http.credentialEncoding` | String | The encoding/charset to use when exchanging credentials with HTTP servers. | `"ISO-8859-1"` | yes