Skip to content

Commit

Permalink
[MRESOLVER-416] New transport "jetty" (#344)
Browse files Browse the repository at this point in the history
This is just the (functional) implementation of Resolver "jetty" HTTP/2 transport, tests are coming as part of MRESOLVER-417.

---

https://issues.apache.org/jira/browse/MRESOLVER-416
  • Loading branch information
cstamas authored Oct 18, 2023
1 parent a6f5024 commit a6a8fc5
Show file tree
Hide file tree
Showing 31 changed files with 2,543 additions and 18 deletions.
6 changes: 6 additions & 0 deletions maven-resolver-demos/maven-resolver-demo-snippets/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@

<properties>
<Automatic-Module-Name>org.apache.maven.resolver.demo.snippets</Automatic-Module-Name>
<!-- To make Jetty work -->
<javaVersion>11</javaVersion>
</properties>

<dependencies>
Expand Down Expand Up @@ -69,6 +71,10 @@
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-transport-jdk</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-transport-jetty</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-supplier</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -37,6 +38,7 @@ protected Map<String, TransporterFactory> getTransporterFactories(
Map<String, ChecksumExtractor> extractors) {
Map<String, TransporterFactory> result = super.getTransporterFactories(extractors);
result.put(JdkTransporterFactory.NAME, new JdkTransporterFactory());
result.put(JettyTransporterFactory.NAME, new JettyTransporterFactory());
return result;
}
}.get();
Expand Down
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-11</artifactId>
<packaging>jar</packaging>

<name>Maven Artifact Resolver Transport JDK (11)</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>11</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>
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@

<parent>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver</artifactId>
<artifactId>maven-resolver-transport-jdk-parent</artifactId>
<version>2.0.0-SNAPSHOT</version>
</parent>

<artifactId>maven-resolver-transport-jdk</artifactId>
<artifactId>maven-resolver-transport-jdk-8</artifactId>
<packaging>jar</packaging>

<name>Maven Artifact Resolver Transport JDK</name>
<name>Maven Artifact Resolver Transport JDK (8)</name>
<description>Maven Artifact Transport JDK Java 11+.</description>

<properties>
Expand Down Expand Up @@ -60,22 +60,22 @@

<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-compiler-plugin</artifactId>
<executions>
<execution>
<id>java11</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<release>11</release>
<multiReleaseOutput>true</multiReleaseOutput>
<compileSourceRoots>src/main/java11</compileSourceRoots>
</configuration>
</execution>
</executions>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
Original file line number Diff line number Diff line change
@@ -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+");
}
}
Loading

0 comments on commit a6a8fc5

Please sign in to comment.