Skip to content
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
9 changes: 8 additions & 1 deletion apache-maven/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,20 @@ under the License.
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-transport-file</artifactId>
</dependency>
<!-- HTTP/1.1, lowest priority, Java8+ (still must as some ITs force it) -->
<dependency>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-transport-wagon</artifactId>
</dependency>
<!-- HTTP/1.1, medium priority, Java8+ -->
<dependency>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-transport-http</artifactId>
</dependency>
<!-- HTTP/1.1 and HTTP/2, high priority, Java11+ -->
<dependency>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-transport-wagon</artifactId>
<artifactId>maven-resolver-transport-jdk</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@
import org.codehaus.plexus.testing.PlexusTest;
import org.codehaus.plexus.util.FileUtils;
import org.eclipse.aether.DefaultRepositorySystemSession;
import org.eclipse.aether.internal.impl.DefaultRepositorySystem;
import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory;
import org.eclipse.aether.repository.LocalRepository;

import static org.codehaus.plexus.testing.PlexusExtension.getBasedir;
import static org.mockito.Mockito.mock;

@PlexusTest
public abstract class AbstractCoreMavenComponentTestCase {
Expand Down Expand Up @@ -150,7 +150,8 @@ protected MavenSession createMavenSession(File pom, Properties executionProperti
getContainer(), configuration.getRepositorySession(), request, new DefaultMavenExecutionResult());
session.setProjects(projects);
session.setAllProjects(session.getProjects());
session.setSession(new DefaultSession(session, new DefaultRepositorySystem(), null, null, null, null));
session.setSession(
new DefaultSession(session, mock(org.eclipse.aether.RepositorySystem.class), null, null, null, null));

return session;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,25 @@ public class DefaultRepositorySystemSessionFactory {

private static final String MAVEN_RESOLVER_TRANSPORT_WAGON = "wagon";

private static final String MAVEN_RESOLVER_TRANSPORT_APACHE = "apache";

private static final String MAVEN_RESOLVER_TRANSPORT_JDK = "jdk";

/**
* This name for Apache HttpClient transport is deprecated.
*
* @deprecated Renamed to {@link #MAVEN_RESOLVER_TRANSPORT_APACHE}
*/
@Deprecated
private static final String MAVEN_RESOLVER_TRANSPORT_NATIVE = "native";

private static final String MAVEN_RESOLVER_TRANSPORT_AUTO = "auto";

private static final String WAGON_TRANSPORTER_PRIORITY_KEY = "aether.priority.WagonTransporterFactory";

private static final String NATIVE_HTTP_TRANSPORTER_PRIORITY_KEY = "aether.priority.HttpTransporterFactory";
private static final String APACHE_HTTP_TRANSPORTER_PRIORITY_KEY = "aether.priority.HttpTransporterFactory";

private static final String JDK_HTTP_TRANSPORTER_PRIORITY_KEY = "aether.priority.JdkTransporterFactory";

private static final String NATIVE_FILE_TRANSPORTER_PRIORITY_KEY = "aether.priority.FileTransporterFactory";

Expand Down Expand Up @@ -322,17 +334,29 @@ public DefaultRepositorySystemSession newRepositorySession(MavenExecutionRequest
Object transport = configProps.getOrDefault(MAVEN_RESOLVER_TRANSPORT_KEY, MAVEN_RESOLVER_TRANSPORT_DEFAULT);
if (MAVEN_RESOLVER_TRANSPORT_DEFAULT.equals(transport)) {
// The "default" mode (user did not set anything) from now on defaults to AUTO
} else if (MAVEN_RESOLVER_TRANSPORT_NATIVE.equals(transport)) {
// Make sure (whatever extra priority is set) that resolver native is selected
} else if (MAVEN_RESOLVER_TRANSPORT_JDK.equals(transport)) {
// Make sure (whatever extra priority is set) that resolver file/jdk is selected
configProps.put(NATIVE_FILE_TRANSPORTER_PRIORITY_KEY, RESOLVER_MAX_PRIORITY);
configProps.put(JDK_HTTP_TRANSPORTER_PRIORITY_KEY, RESOLVER_MAX_PRIORITY);
} else if (MAVEN_RESOLVER_TRANSPORT_APACHE.equals(transport)
|| MAVEN_RESOLVER_TRANSPORT_NATIVE.equals(transport)) {
if (MAVEN_RESOLVER_TRANSPORT_NATIVE.equals(transport)) {
logger.warn(
"Transport name '{}' is DEPRECATED/RENAMED, use '{}' instead",
MAVEN_RESOLVER_TRANSPORT_NATIVE,
MAVEN_RESOLVER_TRANSPORT_APACHE);
}
// Make sure (whatever extra priority is set) that resolver file/apache is selected
configProps.put(NATIVE_FILE_TRANSPORTER_PRIORITY_KEY, RESOLVER_MAX_PRIORITY);
configProps.put(NATIVE_HTTP_TRANSPORTER_PRIORITY_KEY, RESOLVER_MAX_PRIORITY);
configProps.put(APACHE_HTTP_TRANSPORTER_PRIORITY_KEY, RESOLVER_MAX_PRIORITY);
} else if (MAVEN_RESOLVER_TRANSPORT_WAGON.equals(transport)) {
// Make sure (whatever extra priority is set) that wagon is selected
configProps.put(WAGON_TRANSPORTER_PRIORITY_KEY, RESOLVER_MAX_PRIORITY);
} else if (!MAVEN_RESOLVER_TRANSPORT_AUTO.equals(transport)) {
throw new IllegalArgumentException("Unknown resolver transport '" + transport
+ "'. Supported transports are: " + MAVEN_RESOLVER_TRANSPORT_WAGON + ", "
+ MAVEN_RESOLVER_TRANSPORT_NATIVE + ", " + MAVEN_RESOLVER_TRANSPORT_AUTO);
+ MAVEN_RESOLVER_TRANSPORT_APACHE + ", " + MAVEN_RESOLVER_TRANSPORT_JDK + ", "
+ MAVEN_RESOLVER_TRANSPORT_AUTO);
}

session.setUserProperties(request.getUserProperties());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,12 @@
import org.codehaus.plexus.testing.PlexusTest;
import org.codehaus.plexus.util.FileUtils;
import org.eclipse.aether.DefaultRepositorySystemSession;
import org.eclipse.aether.internal.impl.DefaultRepositorySystem;
import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory;
import org.eclipse.aether.repository.LocalRepository;

import static org.codehaus.plexus.testing.PlexusExtension.getBasedir;
import static org.mockito.Mockito.mock;

@PlexusTest
public abstract class AbstractCoreMavenComponentTestCase {
Expand Down Expand Up @@ -149,7 +150,7 @@ protected MavenSession createMavenSession(File pom, Properties executionProperti
getContainer(), configuration.getRepositorySession(), request, new DefaultMavenExecutionResult());
session.setProjects(projects);
session.setAllProjects(session.getProjects());
session.setSession(new DefaultSession(session, new DefaultRepositorySystem(), null, null, null, null));
session.setSession(new DefaultSession(session, mock(RepositorySystem.class), null, null, null, null));

return session;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ void transportConfigurationTest() throws InvalidRepositoryException {

// native
Properties properties = new Properties();
properties.setProperty("maven.resolver.transport", "native");
properties.setProperty("maven.resolver.transport", "apache");
request.setSystemProperties(properties);
Map<String, Object> configProperties =
systemSessionFactory.newRepositorySession(request).getConfigProperties();
Expand All @@ -387,7 +387,7 @@ void transportConfigurationTest() throws InvalidRepositoryException {
IllegalArgumentException exception = assertThrowsExactly(
IllegalArgumentException.class, () -> systemSessionFactory.newRepositorySession(request));
assertEquals(
"Unknown resolver transport 'illegal'. Supported transports are: wagon, native, auto",
"Unknown resolver transport 'illegal'. Supported transports are: wagon, apache, jdk, auto",
exception.getMessage());
properties.remove("maven.resolver.transport");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@
import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.root.RootLocator;
import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.internal.impl.DefaultRepositorySystem;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.mock;

public class DefaultSessionTest {

Expand All @@ -40,7 +41,7 @@ void testRootDirectoryWithNull() {
DefaultMavenExecutionRequest mer = new DefaultMavenExecutionRequest();
MavenSession ms = new MavenSession(null, rss, mer, null);
DefaultSession session =
new DefaultSession(ms, new DefaultRepositorySystem(), Collections.emptyList(), null, null, null);
new DefaultSession(ms, mock(RepositorySystem.class), Collections.emptyList(), null, null, null);

assertEquals(
RootLocator.UNABLE_TO_FIND_ROOT_PROJECT_MESSAGE,
Expand All @@ -55,7 +56,7 @@ void testRootDirectory() {
MavenSession ms = new MavenSession(null, rss, mer, null);
ms.getRequest().setRootDirectory(Paths.get("myRootDirectory"));
DefaultSession session =
new DefaultSession(ms, new DefaultRepositorySystem(), Collections.emptyList(), null, null, null);
new DefaultSession(ms, mock(RepositorySystem.class), Collections.emptyList(), null, null, null);

assertEquals(Paths.get("myRootDirectory"), session.getRootDirectory());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
import org.codehaus.plexus.configuration.DefaultPlexusConfiguration;
import org.codehaus.plexus.util.Os;
import org.eclipse.aether.DefaultRepositorySystemSession;
import org.eclipse.aether.internal.impl.DefaultRepositorySystem;
import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory;
import org.eclipse.aether.repository.LocalRepository;
import org.eclipse.aether.repository.NoLocalRepositoryManagerException;
Expand All @@ -75,6 +75,7 @@
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;

/**
*/
Expand Down Expand Up @@ -419,8 +420,7 @@ private ExpressionEvaluator createExpressionEvaluator(
mavenSession.setCurrentProject(project);
mavenSession.getRequest().setRootDirectory(rootDirectory);

DefaultSession session =
new DefaultSession(mavenSession, new DefaultRepositorySystem(), null, null, null, null);
DefaultSession session = new DefaultSession(mavenSession, mock(RepositorySystem.class), null, null, null, null);

MojoDescriptor mojo = new MojoDescriptor();
mojo.setPluginDescriptor(pluginDescriptor);
Expand Down Expand Up @@ -458,7 +458,7 @@ private MojoExecution newMojoExecution() {
}

private DefaultSession newSession() throws Exception {
return new DefaultSession(newMavenSession(), new DefaultRepositorySystem(), null, null, null, null);
return new DefaultSession(newMavenSession(), mock(RepositorySystem.class), null, null, null, null);
}

private MavenSession newMavenSession() throws Exception {
Expand Down

This file was deleted.

7 changes: 6 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ under the License.
<securityDispatcherVersion>2.0</securityDispatcherVersion>
<cipherVersion>2.0</cipherVersion>
<jxpathVersion>1.3</jxpathVersion>
<resolverVersion>1.9.16</resolverVersion>
<resolverVersion>2.0.0-alpha-1</resolverVersion>
<sisuVersion>0.9.0.M2</sisuVersion>
<asmVersion>9.5</asmVersion>
<slf4jVersion>1.7.36</slf4jVersion>
Expand Down Expand Up @@ -377,6 +377,11 @@ under the License.
<artifactId>maven-resolver-transport-http</artifactId>
<version>${resolverVersion}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-transport-jdk</artifactId>
<version>${resolverVersion}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-transport-wagon</artifactId>
Expand Down