diff --git a/maven-resolver-demos/maven-resolver-demo-snippets/pom.xml b/maven-resolver-demos/maven-resolver-demo-snippets/pom.xml
index 9f48c0327..8f7f22c0c 100644
--- a/maven-resolver-demos/maven-resolver-demo-snippets/pom.xml
+++ b/maven-resolver-demos/maven-resolver-demo-snippets/pom.xml
@@ -34,6 +34,8 @@
org.apache.maven.resolver.demo.snippets
+
+ 11
@@ -69,6 +71,10 @@
org.apache.maven.resolver
maven-resolver-transport-jdk
+
+ org.apache.maven.resolver
+ maven-resolver-transport-jetty
+
org.apache.maven.resolver
maven-resolver-supplier
diff --git a/maven-resolver-demos/maven-resolver-demo-snippets/src/main/java/org/apache/maven/resolver/examples/supplier/SupplierRepositorySystemFactory.java b/maven-resolver-demos/maven-resolver-demo-snippets/src/main/java/org/apache/maven/resolver/examples/supplier/SupplierRepositorySystemFactory.java
index 55c02e4d2..56df8a19a 100644
--- a/maven-resolver-demos/maven-resolver-demo-snippets/src/main/java/org/apache/maven/resolver/examples/supplier/SupplierRepositorySystemFactory.java
+++ b/maven-resolver-demos/maven-resolver-demo-snippets/src/main/java/org/apache/maven/resolver/examples/supplier/SupplierRepositorySystemFactory.java
@@ -25,6 +25,7 @@
import org.eclipse.aether.supplier.RepositorySystemSupplier;
import org.eclipse.aether.transport.http.ChecksumExtractor;
import org.eclipse.aether.transport.jdk.JdkTransporterFactory;
+import org.eclipse.aether.transport.jetty.JettyTransporterFactory;
/**
* A factory for repository system instances that employs Maven Artifact Resolver's provided supplier.
@@ -37,6 +38,7 @@ protected Map getTransporterFactories(
Map extractors) {
Map result = super.getTransporterFactories(extractors);
result.put(JdkTransporterFactory.NAME, new JdkTransporterFactory());
+ result.put(JettyTransporterFactory.NAME, new JettyTransporterFactory());
return result;
}
}.get();
diff --git a/maven-resolver-transport-jdk-parent/maven-resolver-transport-jdk-11/pom.xml b/maven-resolver-transport-jdk-parent/maven-resolver-transport-jdk-11/pom.xml
new file mode 100644
index 000000000..b8f544d8c
--- /dev/null
+++ b/maven-resolver-transport-jdk-parent/maven-resolver-transport-jdk-11/pom.xml
@@ -0,0 +1,85 @@
+
+
+
+ 4.0.0
+
+
+ org.apache.maven.resolver
+ maven-resolver-transport-jdk-parent
+ 2.0.0-SNAPSHOT
+
+
+ maven-resolver-transport-jdk-11
+ jar
+
+ Maven Artifact Resolver Transport JDK (11)
+ Maven Artifact Transport JDK Java 11+.
+
+
+ org.apache.maven.resolver.transport.jdk
+ ${Automatic-Module-Name}
+
+ 11
+
+
+
+
+ org.apache.maven.resolver
+ maven-resolver-api
+
+
+ org.apache.maven.resolver
+ maven-resolver-spi
+
+
+ org.apache.maven.resolver
+ maven-resolver-util
+
+
+ javax.inject
+ javax.inject
+ provided
+ true
+
+
+
+
+
+
+ org.eclipse.sisu
+ sisu-maven-plugin
+
+
+ biz.aQute.bnd
+ bnd-maven-plugin
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+
+
+ ${project.build.outputDirectory}/META-INF/MANIFEST.MF
+
+
+
+
+
+
+
diff --git a/maven-resolver-transport-jdk/src/main/java11/org/eclipse/aether/transport/jdk/JdkHttpException.java b/maven-resolver-transport-jdk-parent/maven-resolver-transport-jdk-11/src/main/java/org/eclipse/aether/transport/jdk/JdkHttpException.java
similarity index 100%
rename from maven-resolver-transport-jdk/src/main/java11/org/eclipse/aether/transport/jdk/JdkHttpException.java
rename to maven-resolver-transport-jdk-parent/maven-resolver-transport-jdk-11/src/main/java/org/eclipse/aether/transport/jdk/JdkHttpException.java
diff --git a/maven-resolver-transport-jdk/src/main/java11/org/eclipse/aether/transport/jdk/JdkHttpTransporter.java b/maven-resolver-transport-jdk-parent/maven-resolver-transport-jdk-11/src/main/java/org/eclipse/aether/transport/jdk/JdkHttpTransporter.java
similarity index 100%
rename from maven-resolver-transport-jdk/src/main/java11/org/eclipse/aether/transport/jdk/JdkHttpTransporter.java
rename to maven-resolver-transport-jdk-parent/maven-resolver-transport-jdk-11/src/main/java/org/eclipse/aether/transport/jdk/JdkHttpTransporter.java
diff --git a/maven-resolver-transport-jdk-parent/maven-resolver-transport-jdk-11/src/main/java/org/eclipse/aether/transport/jdk/JdkTransporterFactory.java b/maven-resolver-transport-jdk-parent/maven-resolver-transport-jdk-11/src/main/java/org/eclipse/aether/transport/jdk/JdkTransporterFactory.java
new file mode 100644
index 000000000..ef076f038
--- /dev/null
+++ b/maven-resolver-transport-jdk-parent/maven-resolver-transport-jdk-11/src/main/java/org/eclipse/aether/transport/jdk/JdkTransporterFactory.java
@@ -0,0 +1,64 @@
+/*
+ * 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 javax.inject.Named;
+
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.repository.RemoteRepository;
+import org.eclipse.aether.spi.connector.transport.Transporter;
+import org.eclipse.aether.spi.connector.transport.TransporterFactory;
+import org.eclipse.aether.transfer.NoTransporterException;
+
+import static java.util.Objects.requireNonNull;
+
+/**
+ * JDK Transport factory.
+ *
+ * @since TBD
+ */
+@Named(JdkTransporterFactory.NAME)
+public final class JdkTransporterFactory implements TransporterFactory {
+ public static final String NAME = "jdk";
+
+ private float priority = 10.0f;
+
+ @Override
+ public float getPriority() {
+ return priority;
+ }
+
+ public JdkTransporterFactory setPriority(float priority) {
+ this.priority = priority;
+ return this;
+ }
+
+ @Override
+ public Transporter newInstance(RepositorySystemSession session, RemoteRepository repository)
+ throws NoTransporterException {
+ requireNonNull(session, "session cannot be null");
+ requireNonNull(repository, "repository cannot be null");
+
+ if (!"http".equalsIgnoreCase(repository.getProtocol()) && !"https".equalsIgnoreCase(repository.getProtocol())) {
+ throw new NoTransporterException(repository, "Only HTTP/HTTPS is supported");
+ }
+
+ return new JdkHttpTransporter(session, repository);
+ }
+}
diff --git a/maven-resolver-transport-jdk/src/main/java11/org/eclipse/aether/transport/jdk/package-info.java b/maven-resolver-transport-jdk-parent/maven-resolver-transport-jdk-11/src/main/java/org/eclipse/aether/transport/jdk/package-info.java
similarity index 100%
rename from maven-resolver-transport-jdk/src/main/java11/org/eclipse/aether/transport/jdk/package-info.java
rename to maven-resolver-transport-jdk-parent/maven-resolver-transport-jdk-11/src/main/java/org/eclipse/aether/transport/jdk/package-info.java
diff --git a/maven-resolver-transport-jdk/pom.xml b/maven-resolver-transport-jdk-parent/maven-resolver-transport-jdk-8/pom.xml
similarity index 77%
rename from maven-resolver-transport-jdk/pom.xml
rename to maven-resolver-transport-jdk-parent/maven-resolver-transport-jdk-8/pom.xml
index c0705e1ae..ff0847481 100644
--- a/maven-resolver-transport-jdk/pom.xml
+++ b/maven-resolver-transport-jdk-parent/maven-resolver-transport-jdk-8/pom.xml
@@ -22,14 +22,14 @@
org.apache.maven.resolver
- maven-resolver
+ maven-resolver-transport-jdk-parent
2.0.0-SNAPSHOT
- maven-resolver-transport-jdk
+ maven-resolver-transport-jdk-8
jar
- Maven Artifact Resolver Transport JDK
+ Maven Artifact Resolver Transport JDK (8)
Maven Artifact Transport JDK Java 11+.
@@ -60,22 +60,22 @@
+
+ org.eclipse.sisu
+ sisu-maven-plugin
+
+
+ biz.aQute.bnd
+ bnd-maven-plugin
+
org.apache.maven.plugins
- maven-compiler-plugin
-
-
- java11
-
- compile
-
-
- 11
- true
- src/main/java11
-
-
-
+ maven-jar-plugin
+
+
+ ${project.build.outputDirectory}/META-INF/MANIFEST.MF
+
+
diff --git a/maven-resolver-transport-jdk-parent/maven-resolver-transport-jdk-8/src/main/java/org/eclipse/aether/transport/jdk/JdkTransporterFactory.java b/maven-resolver-transport-jdk-parent/maven-resolver-transport-jdk-8/src/main/java/org/eclipse/aether/transport/jdk/JdkTransporterFactory.java
new file mode 100644
index 000000000..80dd1d656
--- /dev/null
+++ b/maven-resolver-transport-jdk-parent/maven-resolver-transport-jdk-8/src/main/java/org/eclipse/aether/transport/jdk/JdkTransporterFactory.java
@@ -0,0 +1,60 @@
+/*
+ * 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 javax.inject.Named;
+
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.repository.RemoteRepository;
+import org.eclipse.aether.spi.connector.transport.Transporter;
+import org.eclipse.aether.spi.connector.transport.TransporterFactory;
+import org.eclipse.aether.transfer.NoTransporterException;
+
+import static java.util.Objects.requireNonNull;
+
+/**
+ * JDK Transport factory: on Java 8 is no-op.
+ *
+ * @since TBD
+ */
+@Named(JdkTransporterFactory.NAME)
+public final class JdkTransporterFactory implements TransporterFactory {
+ public static final String NAME = "jdk";
+
+ private float priority = Float.MIN_VALUE;
+
+ @Override
+ public float getPriority() {
+ return priority;
+ }
+
+ public JdkTransporterFactory setPriority(float priority) {
+ this.priority = priority;
+ return this;
+ }
+
+ @Override
+ public Transporter newInstance(RepositorySystemSession session, RemoteRepository repository)
+ throws NoTransporterException {
+ requireNonNull(session, "session cannot be null");
+ requireNonNull(repository, "repository cannot be null");
+
+ throw new NoTransporterException(repository, "JDK Transport needs Java11+");
+ }
+}
diff --git a/maven-resolver-transport-jdk-parent/maven-resolver-transport-jdk/pom.xml b/maven-resolver-transport-jdk-parent/maven-resolver-transport-jdk/pom.xml
new file mode 100644
index 000000000..f6b32f9a7
--- /dev/null
+++ b/maven-resolver-transport-jdk-parent/maven-resolver-transport-jdk/pom.xml
@@ -0,0 +1,128 @@
+
+
+
+ 4.0.0
+
+
+ org.apache.maven.resolver
+ maven-resolver-transport-jdk-parent
+ 2.0.0-SNAPSHOT
+
+
+ maven-resolver-transport-jdk
+ jar
+
+ Maven Artifact Resolver Transport JDK (mr)
+ Maven Artifact Transport JDK Java 11+.
+
+
+ org.apache.maven.resolver.transport.jdk
+ ${Automatic-Module-Name}
+
+
+
+
+ org.apache.maven.resolver
+ maven-resolver-api
+
+
+ org.apache.maven.resolver
+ maven-resolver-spi
+
+
+ org.apache.maven.resolver
+ maven-resolver-util
+
+
+ javax.inject
+ javax.inject
+ provided
+ true
+
+
+
+
+
+
+ false
+ ${project.build.directory}/generated-resources
+
+
+
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+
+
+ java8
+
+ unpack
+
+ generate-resources
+
+
+
+ org.apache.maven.resolver
+ maven-resolver-transport-jdk-8
+ ${project.version}
+ jar
+ ${project.build.directory}/generated-resources
+ META-INF/maven/**
+
+
+
+
+
+ java11
+
+ unpack
+
+ generate-resources
+
+
+
+ org.apache.maven.resolver
+ maven-resolver-transport-jdk-11
+ ${project.version}
+ jar
+ ${project.build.directory}/generated-resources/META-INF/versions/11
+ **/*.class
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+
+
+ ${project.build.outputDirectory}/META-INF/MANIFEST.MF
+
+ true
+
+
+
+
+
+
+
+
diff --git a/maven-resolver-transport-jdk-parent/pom.xml b/maven-resolver-transport-jdk-parent/pom.xml
new file mode 100644
index 000000000..d25f5805d
--- /dev/null
+++ b/maven-resolver-transport-jdk-parent/pom.xml
@@ -0,0 +1,41 @@
+
+
+
+ 4.0.0
+
+
+ org.apache.maven.resolver
+ maven-resolver
+ 2.0.0-SNAPSHOT
+
+
+ maven-resolver-transport-jdk-parent
+ pom
+
+ Maven Artifact Resolver Transport JDK (parent)
+ Maven Artifact Transport JDK Java 11+.
+
+
+ maven-resolver-transport-jdk-8
+ maven-resolver-transport-jdk-11
+ maven-resolver-transport-jdk
+
+
+
diff --git a/maven-resolver-transport-jdk/src/main/java/org/eclipse/aether/transport/jdk/JdkTransporterFactory.java b/maven-resolver-transport-jdk-parent/src/main/java/org/eclipse/aether/transport/jdk/JdkTransporterFactory.java
similarity index 100%
rename from maven-resolver-transport-jdk/src/main/java/org/eclipse/aether/transport/jdk/JdkTransporterFactory.java
rename to maven-resolver-transport-jdk-parent/src/main/java/org/eclipse/aether/transport/jdk/JdkTransporterFactory.java
diff --git a/maven-resolver-transport-jdk-parent/src/main/java11/org/eclipse/aether/transport/jdk/JdkHttpException.java b/maven-resolver-transport-jdk-parent/src/main/java11/org/eclipse/aether/transport/jdk/JdkHttpException.java
new file mode 100644
index 000000000..6aaaead40
--- /dev/null
+++ b/maven-resolver-transport-jdk-parent/src/main/java11/org/eclipse/aether/transport/jdk/JdkHttpException.java
@@ -0,0 +1,37 @@
+/*
+ * 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;
+
+/**
+ * Exception thrown by {@link JdkHttpTransporter} in case of errors.
+ *
+ * @since TBD
+ */
+final class JdkHttpException extends Exception {
+ private final int statusCode;
+
+ JdkHttpException(int statusCode) {
+ super("HTTP Status: " + statusCode);
+ this.statusCode = statusCode;
+ }
+
+ public int getStatusCode() {
+ return statusCode;
+ }
+}
diff --git a/maven-resolver-transport-jdk-parent/src/main/java11/org/eclipse/aether/transport/jdk/JdkHttpTransporter.java b/maven-resolver-transport-jdk-parent/src/main/java11/org/eclipse/aether/transport/jdk/JdkHttpTransporter.java
new file mode 100644
index 000000000..2200aa870
--- /dev/null
+++ b/maven-resolver-transport-jdk-parent/src/main/java11/org/eclipse/aether/transport/jdk/JdkHttpTransporter.java
@@ -0,0 +1,435 @@
+/*
+ * 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 javax.net.ssl.SSLContext;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.Authenticator;
+import java.net.InetSocketAddress;
+import java.net.PasswordAuthentication;
+import java.net.ProxySelector;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.http.HttpClient;
+import java.net.http.HttpRequest;
+import java.net.http.HttpResponse;
+import java.nio.file.Files;
+import java.nio.file.StandardCopyOption;
+import java.nio.file.attribute.FileTime;
+import java.security.NoSuchAlgorithmException;
+import java.time.Duration;
+import java.time.Instant;
+import java.time.ZoneId;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+import java.time.format.DateTimeParseException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.eclipse.aether.ConfigurationProperties;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.repository.AuthenticationContext;
+import org.eclipse.aether.repository.RemoteRepository;
+import org.eclipse.aether.spi.connector.transport.AbstractTransporter;
+import org.eclipse.aether.spi.connector.transport.GetTask;
+import org.eclipse.aether.spi.connector.transport.PeekTask;
+import org.eclipse.aether.spi.connector.transport.PutTask;
+import org.eclipse.aether.spi.connector.transport.TransportTask;
+import org.eclipse.aether.transfer.NoTransporterException;
+import org.eclipse.aether.util.ConfigUtils;
+import org.eclipse.aether.util.FileUtils;
+
+/**
+ * JDK Transport using {@link HttpClient}.
+ *
+ * @since TBD
+ */
+final class JdkHttpTransporter extends AbstractTransporter {
+ private static final int MULTIPLE_CHOICES = 300;
+
+ private static final int NOT_FOUND = 404;
+
+ private static final int PRECONDITION_FAILED = 412;
+
+ private static final long MODIFICATION_THRESHOLD = 60L * 1000L;
+
+ private static final String ACCEPT_ENCODING = "Accept-Encoding";
+
+ private static final String CACHE_CONTROL = "Cache-Control";
+
+ private static final String CONTENT_LENGTH = "Content-Length";
+
+ private static final String CONTENT_RANGE = "Content-Range";
+
+ private static final String IF_UNMODIFIED_SINCE = "If-Unmodified-Since";
+
+ private static final String RANGE = "Range";
+
+ private static final String USER_AGENT = "User-Agent";
+
+ private static final String LAST_MODIFIED = "Last-Modified";
+
+ private static final Pattern CONTENT_RANGE_PATTERN =
+ Pattern.compile("\\s*bytes\\s+([0-9]+)\\s*-\\s*([0-9]+)\\s*/.*");
+
+ private final URI baseUri;
+
+ private final HttpClient client;
+
+ private final Map headers;
+
+ private final int requestTimeout;
+
+ JdkHttpTransporter(RepositorySystemSession session, RemoteRepository repository) throws NoTransporterException {
+ try {
+ URI uri = new URI(repository.getUrl()).parseServerAuthority();
+ if (uri.isOpaque()) {
+ throw new URISyntaxException(repository.getUrl(), "URL must not be opaque");
+ }
+ if (uri.getRawFragment() != null || uri.getRawQuery() != null) {
+ throw new URISyntaxException(repository.getUrl(), "URL must not have fragment or query");
+ }
+ String path = uri.getPath();
+ if (path == null) {
+ path = "/";
+ }
+ if (!path.startsWith("/")) {
+ path = "/" + path;
+ }
+ if (!path.endsWith("/")) {
+ path = path + "/";
+ }
+ this.baseUri = URI.create(uri.getScheme() + "://" + uri.getRawAuthority() + path);
+ } catch (URISyntaxException e) {
+ throw new NoTransporterException(repository, e.getMessage(), e);
+ }
+
+ HashMap headers = new HashMap<>();
+ String userAgent = ConfigUtils.getString(
+ session, ConfigurationProperties.DEFAULT_USER_AGENT, ConfigurationProperties.USER_AGENT);
+ if (userAgent != null) {
+ headers.put(USER_AGENT, userAgent);
+ }
+ @SuppressWarnings("unchecked")
+ Map
+
+ org.apache.maven.resolver
+ maven-resolver-transport-jetty
+ ${project.version}
+
org.apache.maven.resolver
maven-resolver-transport-jdk