Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MRESOLVER-416] New transport "jetty" #344

Merged
merged 6 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading