This is an automated email from the ASF dual-hosted git repository.
cstamas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven.git
The following commit(s) were added to refs/heads/master by this push:
new e6d1b4c5de [MNG-7909] Upgrade to Resolver 2.0.0-alpha-1 (#1282)
e6d1b4c5de is described below
commit e6d1b4c5defb6f0855316b6b96e11111555ea1db
Author: Tamas Cservenak <[email protected]>
AuthorDate: Tue Nov 7 16:06:40 2023 +0100
[MNG-7909] Upgrade to Resolver 2.0.0-alpha-1 (#1282)
Upgrade to Resolver 2.0.0.
Changes:
* many UT code used `new DefaultRepositorySystem()` ctor that is gone (was
present due SL only), replaced with mocks
* dropped MavenResolverModule Guice module (as AetherGuice module is gone
as well)
* updated Resolver version to 2.0.0-alpha-1
* added jdk transport (that prevails apache on Java 11)
* rename of "native" into "apache", deprecate "native" name
* introduce "jdk" transport
---
https://issues.apache.org/jira/browse/MNG-7909
---
apache-maven/pom.xml | 9 ++-
.../maven/AbstractCoreMavenComponentTestCase.java | 5 +-
.../DefaultRepositorySystemSessionFactory.java | 34 ++++++++--
.../maven/AbstractCoreMavenComponentTestCase.java | 5 +-
.../DefaultRepositorySystemSessionFactoryTest.java | 4 +-
.../maven/internal/impl/DefaultSessionTest.java | 7 +-
.../PluginParameterExpressionEvaluatorV4Test.java | 8 +--
.../repository/internal/MavenResolverModule.java | 77 ----------------------
pom.xml | 7 +-
9 files changed, 59 insertions(+), 97 deletions(-)
diff --git a/apache-maven/pom.xml b/apache-maven/pom.xml
index 7704a9a19c..de432eefd0 100644
--- a/apache-maven/pom.xml
+++ b/apache-maven/pom.xml
@@ -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>
diff --git
a/maven-compat/src/test/java/org/apache/maven/AbstractCoreMavenComponentTestCase.java
b/maven-compat/src/test/java/org/apache/maven/AbstractCoreMavenComponentTestCase.java
index 733026c4f0..85fd0c1f5a 100644
---
a/maven-compat/src/test/java/org/apache/maven/AbstractCoreMavenComponentTestCase.java
+++
b/maven-compat/src/test/java/org/apache/maven/AbstractCoreMavenComponentTestCase.java
@@ -51,11 +51,11 @@ import org.codehaus.plexus.PlexusContainer;
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 {
@@ -150,7 +150,8 @@ public abstract class AbstractCoreMavenComponentTestCase {
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;
}
diff --git
a/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java
b/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java
index 215597d6eb..a0e29f1d81 100644
---
a/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java
+++
b/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java
@@ -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";
@@ -322,17 +334,29 @@ public class DefaultRepositorySystemSessionFactory {
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());
diff --git
a/maven-core/src/test/java/org/apache/maven/AbstractCoreMavenComponentTestCase.java
b/maven-core/src/test/java/org/apache/maven/AbstractCoreMavenComponentTestCase.java
index c406898f06..e08814fd48 100644
---
a/maven-core/src/test/java/org/apache/maven/AbstractCoreMavenComponentTestCase.java
+++
b/maven-core/src/test/java/org/apache/maven/AbstractCoreMavenComponentTestCase.java
@@ -50,11 +50,12 @@ import org.codehaus.plexus.PlexusContainer;
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 {
@@ -149,7 +150,7 @@ public abstract class AbstractCoreMavenComponentTestCase {
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;
}
diff --git
a/maven-core/src/test/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactoryTest.java
b/maven-core/src/test/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactoryTest.java
index fe2bbe8b44..f21c07ae6d 100644
---
a/maven-core/src/test/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactoryTest.java
+++
b/maven-core/src/test/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactoryTest.java
@@ -362,7 +362,7 @@ public class DefaultRepositorySystemSessionFactoryTest {
// 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();
@@ -387,7 +387,7 @@ public class DefaultRepositorySystemSessionFactoryTest {
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");
}
diff --git
a/maven-core/src/test/java/org/apache/maven/internal/impl/DefaultSessionTest.java
b/maven-core/src/test/java/org/apache/maven/internal/impl/DefaultSessionTest.java
index dd516c91a3..e8ff9c0443 100644
---
a/maven-core/src/test/java/org/apache/maven/internal/impl/DefaultSessionTest.java
+++
b/maven-core/src/test/java/org/apache/maven/internal/impl/DefaultSessionTest.java
@@ -25,12 +25,13 @@ import
org.apache.maven.execution.DefaultMavenExecutionRequest;
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 {
@@ -40,7 +41,7 @@ public class DefaultSessionTest {
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,
@@ -55,7 +56,7 @@ public class DefaultSessionTest {
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());
}
diff --git
a/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorV4Test.java
b/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorV4Test.java
index 630119241a..cc1c731735 100644
---
a/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorV4Test.java
+++
b/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorV4Test.java
@@ -61,7 +61,7 @@ import
org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator
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;
@@ -75,6 +75,7 @@ import static org.junit.jupiter.api.Assertions.assertNull;
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;
/**
*/
@@ -419,8 +420,7 @@ public class PluginParameterExpressionEvaluatorV4Test
extends AbstractCoreMavenC
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);
@@ -458,7 +458,7 @@ public class PluginParameterExpressionEvaluatorV4Test
extends AbstractCoreMavenC
}
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 {
diff --git
a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenResolverModule.java
b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenResolverModule.java
deleted file mode 100644
index b04cd3aeea..0000000000
---
a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenResolverModule.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * 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.apache.maven.repository.internal;
-
-import javax.inject.Named;
-import javax.inject.Singleton;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.Provides;
-import com.google.inject.name.Names;
-import org.apache.maven.model.building.DefaultModelBuilderFactory;
-import org.apache.maven.model.building.ModelBuilder;
-import org.eclipse.aether.impl.ArtifactDescriptorReader;
-import org.eclipse.aether.impl.MetadataGeneratorFactory;
-import org.eclipse.aether.impl.VersionRangeResolver;
-import org.eclipse.aether.impl.VersionResolver;
-import org.eclipse.aether.impl.guice.AetherModule;
-import org.eclipse.aether.version.VersionScheme;
-
-/**
- * MavenResolverModule
- */
-@Deprecated
-public final class MavenResolverModule extends AbstractModule {
-
- @Override
- protected void configure() {
- install(new AetherModule());
- bind(VersionScheme.class).toProvider(new
DefaultVersionSchemeProvider());
- bind(ArtifactDescriptorReader.class)
- .to(DefaultArtifactDescriptorReader.class)
- .in(Singleton.class);
-
bind(VersionResolver.class).to(DefaultVersionResolver.class).in(Singleton.class);
-
bind(VersionRangeResolver.class).to(DefaultVersionRangeResolver.class).in(Singleton.class);
- bind(MetadataGeneratorFactory.class)
- .annotatedWith(Names.named("snapshot"))
- .to(SnapshotMetadataGeneratorFactory.class)
- .in(Singleton.class);
- bind(MetadataGeneratorFactory.class)
- .annotatedWith(Names.named("versions"))
- .to(VersionsMetadataGeneratorFactory.class)
- .in(Singleton.class);
- bind(ModelBuilder.class).toInstance(new
DefaultModelBuilderFactory().newInstance());
-
bind(ModelCacheFactory.class).to(DefaultModelCacheFactory.class).in(Singleton.class);
- }
-
- @Provides
- @Singleton
- Set<MetadataGeneratorFactory> provideMetadataGeneratorFactories(
- @Named("snapshot") MetadataGeneratorFactory snapshot,
- @Named("versions") MetadataGeneratorFactory versions) {
- Set<MetadataGeneratorFactory> factories = new HashSet<>(2);
- factories.add(snapshot);
- factories.add(versions);
- return Collections.unmodifiableSet(factories);
- }
-}
diff --git a/pom.xml b/pom.xml
index 9ac5ff8b4a..3da4296285 100644
--- a/pom.xml
+++ b/pom.xml
@@ -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>
@@ -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>