-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MRESOLVER-426] Make some HTTP configuration shared (#356)
Many of HTTP related options are not Apache HTTP transport specific. Also, make possible some newer java.net.http.HttpClient options to be applied. --- https://issues.apache.org/jira/browse/MRESOLVER-426
- Loading branch information
Showing
12 changed files
with
493 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...t-jdk-11/src/main/java/org/eclipse/aether/transport/jdk/JdkHttpTransporterCustomizer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.eclipse.aether.transport.jdk; | ||
|
||
import java.net.http.HttpClient; | ||
|
||
import org.eclipse.aether.RepositorySystemSession; | ||
import org.eclipse.aether.repository.RemoteRepository; | ||
|
||
/** | ||
* JDK Transport customizer. | ||
* | ||
* @since TBD | ||
*/ | ||
final class JdkHttpTransporterCustomizer { | ||
private JdkHttpTransporterCustomizer() {} | ||
|
||
static void customizeBuilder( | ||
RepositorySystemSession session, RemoteRepository repository, HttpClient.Builder builder) {} | ||
|
||
static void customizeHttpClient(RepositorySystemSession session, RemoteRepository repository, HttpClient client) {} | ||
} |
85 changes: 85 additions & 0 deletions
85
maven-resolver-transport-jdk-parent/maven-resolver-transport-jdk-19/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Licensed to the Apache Software Foundation (ASF) under one | ||
or more contributor license agreements. See the NOTICE file | ||
distributed with this work for additional information | ||
regarding copyright ownership. The ASF licenses this file | ||
to you under the Apache License, Version 2.0 (the | ||
"License"); you may not use this file except in compliance | ||
with the License. You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, | ||
software distributed under the License is distributed on an | ||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, either express or implied. See the License for the | ||
specific language governing permissions and limitations | ||
under the License. | ||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.apache.maven.resolver</groupId> | ||
<artifactId>maven-resolver-transport-jdk-parent</artifactId> | ||
<version>2.0.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>maven-resolver-transport-jdk-19</artifactId> | ||
<packaging>jar</packaging> | ||
|
||
<name>Maven Artifact Resolver Transport JDK (19)</name> | ||
<description>Maven Artifact Transport JDK Java 11+.</description> | ||
|
||
<properties> | ||
<Automatic-Module-Name>org.apache.maven.resolver.transport.jdk</Automatic-Module-Name> | ||
<Bundle-SymbolicName>${Automatic-Module-Name}</Bundle-SymbolicName> | ||
|
||
<javaVersion>19</javaVersion> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.maven.resolver</groupId> | ||
<artifactId>maven-resolver-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.maven.resolver</groupId> | ||
<artifactId>maven-resolver-spi</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.maven.resolver</groupId> | ||
<artifactId>maven-resolver-util</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>javax.inject</groupId> | ||
<artifactId>javax.inject</artifactId> | ||
<scope>provided</scope> | ||
<optional>true</optional> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.eclipse.sisu</groupId> | ||
<artifactId>sisu-maven-plugin</artifactId> | ||
</plugin> | ||
<plugin> | ||
<groupId>biz.aQute.bnd</groupId> | ||
<artifactId>bnd-maven-plugin</artifactId> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<configuration> | ||
<archive> | ||
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile> | ||
</archive> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
68 changes: 68 additions & 0 deletions
68
...t-jdk-19/src/main/java/org/eclipse/aether/transport/jdk/JdkHttpTransporterCustomizer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.eclipse.aether.transport.jdk; | ||
|
||
import java.net.InetAddress; | ||
import java.net.UnknownHostException; | ||
import java.net.http.HttpClient; | ||
|
||
import org.eclipse.aether.ConfigurationProperties; | ||
import org.eclipse.aether.RepositorySystemSession; | ||
import org.eclipse.aether.repository.RemoteRepository; | ||
import org.eclipse.aether.util.ConfigUtils; | ||
|
||
/** | ||
* JDK Transport customizer. | ||
* | ||
* @since TBD | ||
*/ | ||
final class JdkHttpTransporterCustomizer { | ||
private JdkHttpTransporterCustomizer() {} | ||
|
||
static void customizeBuilder( | ||
RepositorySystemSession session, RemoteRepository repository, HttpClient.Builder builder) { | ||
InetAddress localAddress = getHttpLocalAddress(session, repository); | ||
if (localAddress != null) { | ||
builder.localAddress(localAddress); | ||
} | ||
} | ||
|
||
static void customizeHttpClient(RepositorySystemSession session, RemoteRepository repository, HttpClient client) {} | ||
|
||
/** | ||
* Returns non-null {@link InetAddress} if set in configuration, {@code null} otherwise. | ||
*/ | ||
private static InetAddress getHttpLocalAddress(RepositorySystemSession session, RemoteRepository repository) { | ||
String bindAddress = ConfigUtils.getString( | ||
session, | ||
null, | ||
ConfigurationProperties.HTTP_LOCAL_ADDRESS + "." + repository.getId(), | ||
ConfigurationProperties.HTTP_LOCAL_ADDRESS); | ||
if (bindAddress == null) { | ||
return null; | ||
} | ||
try { | ||
return InetAddress.getByName(bindAddress); | ||
} catch (UnknownHostException uhe) { | ||
throw new IllegalArgumentException( | ||
"Given bind address (" + bindAddress + ") cannot be resolved for remote repository " + repository, | ||
uhe); | ||
} | ||
} | ||
} |
Oops, something went wrong.