bundle
diff --git a/maven-resolver-named-locks/pom.xml b/maven-resolver-named-locks/pom.xml
index 27a320478..bb8f3dab2 100644
--- a/maven-resolver-named-locks/pom.xml
+++ b/maven-resolver-named-locks/pom.xml
@@ -23,7 +23,7 @@
org.apache.maven.resolver
maven-resolver
- 1.9.15-SNAPSHOT
+ 2.0.0-SNAPSHOT
maven-resolver-named-locks
diff --git a/maven-resolver-spi/pom.xml b/maven-resolver-spi/pom.xml
index 53bf13e11..78bfe7ac9 100644
--- a/maven-resolver-spi/pom.xml
+++ b/maven-resolver-spi/pom.xml
@@ -23,7 +23,7 @@
org.apache.maven.resolver
maven-resolver
- 1.9.15-SNAPSHOT
+ 2.0.0-SNAPSHOT
maven-resolver-spi
diff --git a/maven-resolver-spi/src/main/java/org/eclipse/aether/spi/locator/Service.java b/maven-resolver-spi/src/main/java/org/eclipse/aether/spi/locator/Service.java
index dcdf2c503..077c7662d 100644
--- a/maven-resolver-spi/src/main/java/org/eclipse/aether/spi/locator/Service.java
+++ b/maven-resolver-spi/src/main/java/org/eclipse/aether/spi/locator/Service.java
@@ -23,7 +23,8 @@
* means to programmatically wire the several components of the repository system together when it is used outside of an
* IoC container.
*
- * @deprecated Use some out-of-the-box DI implementation instead.
+ * @deprecated Use of out-of-the-box DI implementation recommended, or, as alternative new supplier from
+ * module {@code maven-resolver-supplier}.
*/
@Deprecated
public interface Service {
diff --git a/maven-resolver-spi/src/main/java/org/eclipse/aether/spi/locator/ServiceLocator.java b/maven-resolver-spi/src/main/java/org/eclipse/aether/spi/locator/ServiceLocator.java
index 5de51268a..ac2f34a60 100644
--- a/maven-resolver-spi/src/main/java/org/eclipse/aether/spi/locator/ServiceLocator.java
+++ b/maven-resolver-spi/src/main/java/org/eclipse/aether/spi/locator/ServiceLocator.java
@@ -32,7 +32,8 @@
* to acquire the repository system. Components that implement {@link Service} will be given an opportunity to acquire
* further components from the locator, thereby allowing to create the complete object graph of the repository system.
*
- * @deprecated Use some out-of-the-box DI implementation instead.
+ * @deprecated Use of out-of-the-box DI implementation recommended, or, as alternative new supplier from
+ * module {@code maven-resolver-supplier}.
*/
@Deprecated
public interface ServiceLocator {
diff --git a/maven-resolver-spi/src/main/java/org/eclipse/aether/spi/locator/package-info.java b/maven-resolver-spi/src/main/java/org/eclipse/aether/spi/locator/package-info.java
index e3d149387..75c08b6c8 100644
--- a/maven-resolver-spi/src/main/java/org/eclipse/aether/spi/locator/package-info.java
+++ b/maven-resolver-spi/src/main/java/org/eclipse/aether/spi/locator/package-info.java
@@ -19,7 +19,7 @@
*/
/**
* A lightweight service locator infrastructure to help components acquire dependent components. The implementation of
- * the repository system is decomposed into many sub components that interact with each other via interfaces, allowing
+ * the repository system is decomposed into many subcomponents that interact with each other via interfaces, allowing
* an application to customize the system by swapping in different implementation classes for these interfaces. The
* service locator defined by this package is one means for components to get hold of the proper implementation for its
* dependencies. While not the most popular approach to component wiring, this service locator enables applications
@@ -27,6 +27,7 @@
* footprint. Therefore, all components should implement {@link org.eclipse.aether.spi.locator.Service} to support this
* goal.
*
- * @deprecated Use some out-of-the-box DI implementation instead.
+ * @deprecated Use of out-of-the-box DI implementation recommended, or, as alternative new supplier from
+ * module {@code maven-resolver-supplier}.
*/
package org.eclipse.aether.spi.locator;
diff --git a/maven-resolver-supplier/pom.xml b/maven-resolver-supplier/pom.xml
new file mode 100644
index 000000000..fee4e6e2a
--- /dev/null
+++ b/maven-resolver-supplier/pom.xml
@@ -0,0 +1,148 @@
+
+
+
+ 4.0.0
+
+
+ org.apache.maven.resolver
+ maven-resolver
+ 2.0.0-SNAPSHOT
+
+
+ maven-resolver-supplier
+
+ Maven Artifact Resolver Instance Supplier
+ A helper module to provide RepositorySystem instances.
+
+
+ org.apache.maven.resolver.supplier
+ ${Automatic-Module-Name}
+
+
+
+
+ org.apache.maven.resolver
+ maven-resolver-api
+
+
+ org.apache.maven.resolver
+ maven-resolver-util
+
+
+ org.apache.maven.resolver
+ maven-resolver-spi
+
+
+ org.apache.maven.resolver
+ maven-resolver-named-locks
+
+
+ org.apache.maven.resolver
+ maven-resolver-impl
+
+
+ org.apache.maven.resolver
+ maven-resolver-connector-basic
+
+
+ org.apache.maven.resolver
+ maven-resolver-transport-file
+
+
+ org.apache.maven.resolver
+ maven-resolver-transport-http
+
+
+
+ org.apache.maven
+ maven-resolver-provider
+ ${mavenVersion}
+
+
+ javax.inject
+ javax.inject
+
+
+ org.eclipse.sisu
+ org.eclipse.sisu.inject
+
+
+
+
+ org.apache.maven
+ maven-model-builder
+ ${mavenVersion}
+
+
+ javax.inject
+ javax.inject
+
+
+ org.eclipse.sisu
+ org.eclipse.sisu.inject
+
+
+
+
+
+ org.slf4j
+ slf4j-api
+
+
+
+ org.slf4j
+ slf4j-simple
+ test
+
+
+ org.hamcrest
+ hamcrest
+ test
+
+
+ org.hamcrest
+ hamcrest-core
+ test
+
+
+ junit
+ junit
+ test
+
+
+
+
+
+
+ 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-supplier/src/main/java/org/eclipse/aether/supplier/RepositorySystemSupplier.java b/maven-resolver-supplier/src/main/java/org/eclipse/aether/supplier/RepositorySystemSupplier.java
new file mode 100644
index 000000000..795265679
--- /dev/null
+++ b/maven-resolver-supplier/src/main/java/org/eclipse/aether/supplier/RepositorySystemSupplier.java
@@ -0,0 +1,638 @@
+/*
+ * 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.supplier;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.function.Supplier;
+
+import org.apache.maven.model.building.DefaultModelBuilderFactory;
+import org.apache.maven.model.building.ModelBuilder;
+import org.apache.maven.repository.internal.DefaultArtifactDescriptorReader;
+import org.apache.maven.repository.internal.DefaultModelCacheFactory;
+import org.apache.maven.repository.internal.DefaultVersionRangeResolver;
+import org.apache.maven.repository.internal.DefaultVersionResolver;
+import org.apache.maven.repository.internal.ModelCacheFactory;
+import org.apache.maven.repository.internal.PluginsMetadataGeneratorFactory;
+import org.apache.maven.repository.internal.SnapshotMetadataGeneratorFactory;
+import org.apache.maven.repository.internal.VersionsMetadataGeneratorFactory;
+import org.eclipse.aether.RepositoryListener;
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.connector.basic.BasicRepositoryConnectorFactory;
+import org.eclipse.aether.impl.ArtifactDescriptorReader;
+import org.eclipse.aether.impl.ArtifactResolver;
+import org.eclipse.aether.impl.DependencyCollector;
+import org.eclipse.aether.impl.Deployer;
+import org.eclipse.aether.impl.Installer;
+import org.eclipse.aether.impl.LocalRepositoryProvider;
+import org.eclipse.aether.impl.MetadataGeneratorFactory;
+import org.eclipse.aether.impl.MetadataResolver;
+import org.eclipse.aether.impl.OfflineController;
+import org.eclipse.aether.impl.RemoteRepositoryFilterManager;
+import org.eclipse.aether.impl.RemoteRepositoryManager;
+import org.eclipse.aether.impl.RepositoryConnectorProvider;
+import org.eclipse.aether.impl.RepositoryEventDispatcher;
+import org.eclipse.aether.impl.RepositorySystemLifecycle;
+import org.eclipse.aether.impl.UpdateCheckManager;
+import org.eclipse.aether.impl.UpdatePolicyAnalyzer;
+import org.eclipse.aether.impl.VersionRangeResolver;
+import org.eclipse.aether.impl.VersionResolver;
+import org.eclipse.aether.internal.impl.DefaultArtifactResolver;
+import org.eclipse.aether.internal.impl.DefaultChecksumPolicyProvider;
+import org.eclipse.aether.internal.impl.DefaultDeployer;
+import org.eclipse.aether.internal.impl.DefaultFileProcessor;
+import org.eclipse.aether.internal.impl.DefaultInstaller;
+import org.eclipse.aether.internal.impl.DefaultLocalPathComposer;
+import org.eclipse.aether.internal.impl.DefaultLocalPathPrefixComposerFactory;
+import org.eclipse.aether.internal.impl.DefaultLocalRepositoryProvider;
+import org.eclipse.aether.internal.impl.DefaultMetadataResolver;
+import org.eclipse.aether.internal.impl.DefaultOfflineController;
+import org.eclipse.aether.internal.impl.DefaultRemoteRepositoryManager;
+import org.eclipse.aether.internal.impl.DefaultRepositoryConnectorProvider;
+import org.eclipse.aether.internal.impl.DefaultRepositoryEventDispatcher;
+import org.eclipse.aether.internal.impl.DefaultRepositoryLayoutProvider;
+import org.eclipse.aether.internal.impl.DefaultRepositorySystem;
+import org.eclipse.aether.internal.impl.DefaultRepositorySystemLifecycle;
+import org.eclipse.aether.internal.impl.DefaultTrackingFileManager;
+import org.eclipse.aether.internal.impl.DefaultTransporterProvider;
+import org.eclipse.aether.internal.impl.DefaultUpdateCheckManager;
+import org.eclipse.aether.internal.impl.DefaultUpdatePolicyAnalyzer;
+import org.eclipse.aether.internal.impl.EnhancedLocalRepositoryManagerFactory;
+import org.eclipse.aether.internal.impl.LocalPathComposer;
+import org.eclipse.aether.internal.impl.LocalPathPrefixComposerFactory;
+import org.eclipse.aether.internal.impl.Maven2RepositoryLayoutFactory;
+import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory;
+import org.eclipse.aether.internal.impl.TrackingFileManager;
+import org.eclipse.aether.internal.impl.checksum.DefaultChecksumAlgorithmFactorySelector;
+import org.eclipse.aether.internal.impl.checksum.Md5ChecksumAlgorithmFactory;
+import org.eclipse.aether.internal.impl.checksum.Sha1ChecksumAlgorithmFactory;
+import org.eclipse.aether.internal.impl.checksum.Sha256ChecksumAlgorithmFactory;
+import org.eclipse.aether.internal.impl.checksum.Sha512ChecksumAlgorithmFactory;
+import org.eclipse.aether.internal.impl.checksum.SparseDirectoryTrustedChecksumsSource;
+import org.eclipse.aether.internal.impl.checksum.SummaryFileTrustedChecksumsSource;
+import org.eclipse.aether.internal.impl.checksum.TrustedToProvidedChecksumsSourceAdapter;
+import org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector;
+import org.eclipse.aether.internal.impl.collect.DependencyCollectorDelegate;
+import org.eclipse.aether.internal.impl.collect.bf.BfDependencyCollector;
+import org.eclipse.aether.internal.impl.collect.df.DfDependencyCollector;
+import org.eclipse.aether.internal.impl.filter.DefaultRemoteRepositoryFilterManager;
+import org.eclipse.aether.internal.impl.filter.GroupIdRemoteRepositoryFilterSource;
+import org.eclipse.aether.internal.impl.filter.PrefixesRemoteRepositoryFilterSource;
+import org.eclipse.aether.internal.impl.resolution.TrustedChecksumsArtifactResolverPostProcessor;
+import org.eclipse.aether.internal.impl.synccontext.DefaultSyncContextFactory;
+import org.eclipse.aether.internal.impl.synccontext.named.NameMapper;
+import org.eclipse.aether.internal.impl.synccontext.named.NameMappers;
+import org.eclipse.aether.internal.impl.synccontext.named.NamedLockFactoryAdapterFactory;
+import org.eclipse.aether.internal.impl.synccontext.named.NamedLockFactoryAdapterFactoryImpl;
+import org.eclipse.aether.named.NamedLockFactory;
+import org.eclipse.aether.named.providers.FileLockNamedLockFactory;
+import org.eclipse.aether.named.providers.LocalReadWriteLockNamedLockFactory;
+import org.eclipse.aether.named.providers.LocalSemaphoreNamedLockFactory;
+import org.eclipse.aether.named.providers.NoopNamedLockFactory;
+import org.eclipse.aether.spi.checksums.ProvidedChecksumsSource;
+import org.eclipse.aether.spi.checksums.TrustedChecksumsSource;
+import org.eclipse.aether.spi.connector.RepositoryConnectorFactory;
+import org.eclipse.aether.spi.connector.checksum.ChecksumAlgorithmFactory;
+import org.eclipse.aether.spi.connector.checksum.ChecksumAlgorithmFactorySelector;
+import org.eclipse.aether.spi.connector.checksum.ChecksumPolicyProvider;
+import org.eclipse.aether.spi.connector.filter.RemoteRepositoryFilterSource;
+import org.eclipse.aether.spi.connector.layout.RepositoryLayoutFactory;
+import org.eclipse.aether.spi.connector.layout.RepositoryLayoutProvider;
+import org.eclipse.aether.spi.connector.transport.TransporterFactory;
+import org.eclipse.aether.spi.connector.transport.TransporterProvider;
+import org.eclipse.aether.spi.io.FileProcessor;
+import org.eclipse.aether.spi.localrepo.LocalRepositoryManagerFactory;
+import org.eclipse.aether.spi.resolution.ArtifactResolverPostProcessor;
+import org.eclipse.aether.spi.synccontext.SyncContextFactory;
+import org.eclipse.aether.transport.file.FileTransporterFactory;
+import org.eclipse.aether.transport.http.ChecksumExtractor;
+import org.eclipse.aether.transport.http.HttpTransporterFactory;
+import org.eclipse.aether.transport.http.Nexus2ChecksumExtractor;
+import org.eclipse.aether.transport.http.XChecksumChecksumExtractor;
+
+/**
+ * A simple {@link Supplier} of {@link org.eclipse.aether.RepositorySystem} instances, that on each call supplies newly
+ * constructed instance. For proper shut down, use {@link RepositorySystem#shutdown()} method on supplied instance(s).
+ *
+ * Extend this class and override methods to customize, if needed.
+ *
+ * @since 1.9.15
+ */
+public class RepositorySystemSupplier implements Supplier {
+ protected FileProcessor getFileProcessor() {
+ return new DefaultFileProcessor();
+ }
+
+ protected TrackingFileManager getTrackingFileManager() {
+ return new DefaultTrackingFileManager();
+ }
+
+ protected LocalPathComposer getLocalPathComposer() {
+ return new DefaultLocalPathComposer();
+ }
+
+ protected LocalPathPrefixComposerFactory getLocalPathPrefixComposerFactory() {
+ return new DefaultLocalPathPrefixComposerFactory();
+ }
+
+ protected RepositorySystemLifecycle getRepositorySystemLifecycle() {
+ return new DefaultRepositorySystemLifecycle();
+ }
+
+ protected OfflineController getOfflineController() {
+ return new DefaultOfflineController();
+ }
+
+ protected UpdatePolicyAnalyzer getUpdatePolicyAnalyzer() {
+ return new DefaultUpdatePolicyAnalyzer();
+ }
+
+ protected ChecksumPolicyProvider getChecksumPolicyProvider() {
+ return new DefaultChecksumPolicyProvider();
+ }
+
+ protected UpdateCheckManager getUpdateCheckManager(
+ TrackingFileManager trackingFileManager, UpdatePolicyAnalyzer updatePolicyAnalyzer) {
+ return new DefaultUpdateCheckManager(trackingFileManager, updatePolicyAnalyzer);
+ }
+
+ protected Map getNamedLockFactories() {
+ HashMap result = new HashMap<>();
+ result.put(NoopNamedLockFactory.NAME, new NoopNamedLockFactory());
+ result.put(LocalReadWriteLockNamedLockFactory.NAME, new LocalReadWriteLockNamedLockFactory());
+ result.put(LocalSemaphoreNamedLockFactory.NAME, new LocalSemaphoreNamedLockFactory());
+ result.put(FileLockNamedLockFactory.NAME, new FileLockNamedLockFactory());
+ return result;
+ }
+
+ protected Map getNameMappers() {
+ HashMap result = new HashMap<>();
+ result.put(NameMappers.STATIC_NAME, NameMappers.staticNameMapper());
+ result.put(NameMappers.GAV_NAME, NameMappers.gavNameMapper());
+ result.put(NameMappers.DISCRIMINATING_NAME, NameMappers.discriminatingNameMapper());
+ result.put(NameMappers.FILE_GAV_NAME, NameMappers.fileGavNameMapper());
+ result.put(NameMappers.FILE_HGAV_NAME, NameMappers.fileHashingGavNameMapper());
+ return result;
+ }
+
+ protected NamedLockFactoryAdapterFactory getNamedLockFactoryAdapterFactory(
+ Map namedLockFactories,
+ Map nameMappers,
+ RepositorySystemLifecycle repositorySystemLifecycle) {
+ return new NamedLockFactoryAdapterFactoryImpl(namedLockFactories, nameMappers, repositorySystemLifecycle);
+ }
+
+ protected SyncContextFactory getSyncContextFactory(NamedLockFactoryAdapterFactory namedLockFactoryAdapterFactory) {
+ return new DefaultSyncContextFactory(namedLockFactoryAdapterFactory);
+ }
+
+ protected Map getChecksumAlgorithmFactories() {
+ HashMap result = new HashMap<>();
+ result.put(Sha512ChecksumAlgorithmFactory.NAME, new Sha512ChecksumAlgorithmFactory());
+ result.put(Sha256ChecksumAlgorithmFactory.NAME, new Sha256ChecksumAlgorithmFactory());
+ result.put(Sha1ChecksumAlgorithmFactory.NAME, new Sha1ChecksumAlgorithmFactory());
+ result.put(Md5ChecksumAlgorithmFactory.NAME, new Md5ChecksumAlgorithmFactory());
+ return result;
+ }
+
+ protected ChecksumAlgorithmFactorySelector getChecksumAlgorithmFactorySelector(
+ Map checksumAlgorithmFactories) {
+ return new DefaultChecksumAlgorithmFactorySelector(checksumAlgorithmFactories);
+ }
+
+ protected Map getRepositoryLayoutFactories(
+ ChecksumAlgorithmFactorySelector checksumAlgorithmFactorySelector) {
+ HashMap result = new HashMap<>();
+ result.put(
+ Maven2RepositoryLayoutFactory.NAME,
+ new Maven2RepositoryLayoutFactory(checksumAlgorithmFactorySelector));
+ return result;
+ }
+
+ protected RepositoryLayoutProvider getRepositoryLayoutProvider(
+ Map repositoryLayoutFactories) {
+ return new DefaultRepositoryLayoutProvider(new HashSet<>(repositoryLayoutFactories.values()));
+ }
+
+ protected LocalRepositoryProvider getLocalRepositoryProvider(
+ LocalPathComposer localPathComposer,
+ TrackingFileManager trackingFileManager,
+ LocalPathPrefixComposerFactory localPathPrefixComposerFactory) {
+ HashSet localRepositoryProviders = new HashSet<>(2);
+ localRepositoryProviders.add(new SimpleLocalRepositoryManagerFactory(localPathComposer));
+ localRepositoryProviders.add(new EnhancedLocalRepositoryManagerFactory(
+ localPathComposer, trackingFileManager, localPathPrefixComposerFactory));
+ return new DefaultLocalRepositoryProvider(localRepositoryProviders);
+ }
+
+ protected RemoteRepositoryManager getRemoteRepositoryManager(
+ UpdatePolicyAnalyzer updatePolicyAnalyzer, ChecksumPolicyProvider checksumPolicyProvider) {
+ return new DefaultRemoteRepositoryManager(updatePolicyAnalyzer, checksumPolicyProvider);
+ }
+
+ protected Map getRemoteRepositoryFilterSources(
+ RepositorySystemLifecycle repositorySystemLifecycle, RepositoryLayoutProvider repositoryLayoutProvider) {
+ HashMap result = new HashMap<>();
+ result.put(
+ GroupIdRemoteRepositoryFilterSource.NAME,
+ new GroupIdRemoteRepositoryFilterSource(repositorySystemLifecycle));
+ result.put(
+ PrefixesRemoteRepositoryFilterSource.NAME,
+ new PrefixesRemoteRepositoryFilterSource(repositoryLayoutProvider));
+ return result;
+ }
+
+ protected RemoteRepositoryFilterManager getRemoteRepositoryFilterManager(
+ Map remoteRepositoryFilterSources) {
+ return new DefaultRemoteRepositoryFilterManager(remoteRepositoryFilterSources);
+ }
+
+ protected Map getRepositoryListeners() {
+ return new HashMap<>();
+ }
+
+ protected RepositoryEventDispatcher getRepositoryEventDispatcher(
+ Map repositoryListeners) {
+ return new DefaultRepositoryEventDispatcher(new HashSet<>(repositoryListeners.values()));
+ }
+
+ protected Map getTrustedChecksumsSources(
+ FileProcessor fileProcessor,
+ LocalPathComposer localPathComposer,
+ RepositorySystemLifecycle repositorySystemLifecycle) {
+ HashMap result = new HashMap<>();
+ result.put(
+ SparseDirectoryTrustedChecksumsSource.NAME,
+ new SparseDirectoryTrustedChecksumsSource(fileProcessor, localPathComposer));
+ result.put(
+ SummaryFileTrustedChecksumsSource.NAME,
+ new SummaryFileTrustedChecksumsSource(localPathComposer, repositorySystemLifecycle));
+ return result;
+ }
+
+ protected Map getProvidedChecksumsSources(
+ Map trustedChecksumsSources) {
+ HashMap result = new HashMap<>();
+ result.put(
+ TrustedToProvidedChecksumsSourceAdapter.NAME,
+ new TrustedToProvidedChecksumsSourceAdapter(trustedChecksumsSources));
+ return result;
+ }
+
+ protected Map getChecksumExtractors() {
+ HashMap result = new HashMap<>();
+ result.put(Nexus2ChecksumExtractor.NAME, new Nexus2ChecksumExtractor());
+ result.put(XChecksumChecksumExtractor.NAME, new XChecksumChecksumExtractor());
+ return result;
+ }
+
+ protected Map getTransporterFactories(Map extractors) {
+ HashMap result = new HashMap<>();
+ result.put(FileTransporterFactory.NAME, new FileTransporterFactory());
+ result.put(HttpTransporterFactory.NAME, new HttpTransporterFactory(extractors));
+ return result;
+ }
+
+ protected TransporterProvider getTransporterProvider(Map transporterFactories) {
+ return new DefaultTransporterProvider(new HashSet<>(transporterFactories.values()));
+ }
+
+ protected BasicRepositoryConnectorFactory getBasicRepositoryConnectorFactory(
+ TransporterProvider transporterProvider,
+ RepositoryLayoutProvider repositoryLayoutProvider,
+ ChecksumPolicyProvider checksumPolicyProvider,
+ FileProcessor fileProcessor,
+ Map providedChecksumsSources) {
+ return new BasicRepositoryConnectorFactory(
+ transporterProvider,
+ repositoryLayoutProvider,
+ checksumPolicyProvider,
+ fileProcessor,
+ providedChecksumsSources);
+ }
+
+ protected Map getRepositoryConnectorFactories(
+ BasicRepositoryConnectorFactory basicRepositoryConnectorFactory) {
+ HashMap result = new HashMap<>();
+ result.put(BasicRepositoryConnectorFactory.NAME, basicRepositoryConnectorFactory);
+ return result;
+ }
+
+ protected RepositoryConnectorProvider getRepositoryConnectorProvider(
+ Map repositoryConnectorFactories,
+ RemoteRepositoryFilterManager remoteRepositoryFilterManager) {
+ return new DefaultRepositoryConnectorProvider(
+ new HashSet<>(repositoryConnectorFactories.values()), remoteRepositoryFilterManager);
+ }
+
+ protected Installer getInstaller(
+ FileProcessor fileProcessor,
+ RepositoryEventDispatcher repositoryEventDispatcher,
+ Map metadataGeneratorFactories,
+ SyncContextFactory syncContextFactory) {
+ return new DefaultInstaller(
+ fileProcessor,
+ repositoryEventDispatcher,
+ new HashSet<>(metadataGeneratorFactories.values()),
+ syncContextFactory);
+ }
+
+ @SuppressWarnings("checkstyle:parameternumber")
+ protected Deployer getDeployer(
+ FileProcessor fileProcessor,
+ RepositoryEventDispatcher repositoryEventDispatcher,
+ RepositoryConnectorProvider repositoryConnectorProvider,
+ RemoteRepositoryManager remoteRepositoryManager,
+ UpdateCheckManager updateCheckManager,
+ Map metadataGeneratorFactories,
+ SyncContextFactory syncContextFactory,
+ OfflineController offlineController) {
+ return new DefaultDeployer(
+ fileProcessor,
+ repositoryEventDispatcher,
+ repositoryConnectorProvider,
+ remoteRepositoryManager,
+ updateCheckManager,
+ new HashSet<>(metadataGeneratorFactories.values()),
+ syncContextFactory,
+ offlineController);
+ }
+
+ protected Map getDependencyCollectorDelegates(
+ RemoteRepositoryManager remoteRepositoryManager,
+ ArtifactDescriptorReader artifactDescriptorReader,
+ VersionRangeResolver versionRangeResolver) {
+ HashMap result = new HashMap<>();
+ result.put(
+ DfDependencyCollector.NAME,
+ new DfDependencyCollector(remoteRepositoryManager, artifactDescriptorReader, versionRangeResolver));
+ result.put(
+ BfDependencyCollector.NAME,
+ new BfDependencyCollector(remoteRepositoryManager, artifactDescriptorReader, versionRangeResolver));
+ return result;
+ }
+
+ protected DependencyCollector getDependencyCollector(
+ Map dependencyCollectorDelegates) {
+ return new DefaultDependencyCollector(dependencyCollectorDelegates);
+ }
+
+ protected Map getArtifactResolverPostProcessors(
+ ChecksumAlgorithmFactorySelector checksumAlgorithmFactorySelector,
+ Map trustedChecksumsSources) {
+ HashMap result = new HashMap<>();
+ result.put(
+ TrustedChecksumsArtifactResolverPostProcessor.NAME,
+ new TrustedChecksumsArtifactResolverPostProcessor(
+ checksumAlgorithmFactorySelector, trustedChecksumsSources));
+ return result;
+ }
+
+ @SuppressWarnings("checkstyle:parameternumber")
+ protected ArtifactResolver getArtifactResolver(
+ FileProcessor fileProcessor,
+ RepositoryEventDispatcher repositoryEventDispatcher,
+ VersionResolver versionResolver,
+ UpdateCheckManager updateCheckManager,
+ RepositoryConnectorProvider repositoryConnectorProvider,
+ RemoteRepositoryManager remoteRepositoryManager,
+ SyncContextFactory syncContextFactory,
+ OfflineController offlineController,
+ Map artifactResolverPostProcessors,
+ RemoteRepositoryFilterManager remoteRepositoryFilterManager) {
+ return new DefaultArtifactResolver(
+ fileProcessor,
+ repositoryEventDispatcher,
+ versionResolver,
+ updateCheckManager,
+ repositoryConnectorProvider,
+ remoteRepositoryManager,
+ syncContextFactory,
+ offlineController,
+ artifactResolverPostProcessors,
+ remoteRepositoryFilterManager);
+ }
+
+ protected MetadataResolver getMetadataResolver(
+ RepositoryEventDispatcher repositoryEventDispatcher,
+ UpdateCheckManager updateCheckManager,
+ RepositoryConnectorProvider repositoryConnectorProvider,
+ RemoteRepositoryManager remoteRepositoryManager,
+ SyncContextFactory syncContextFactory,
+ OfflineController offlineController,
+ RemoteRepositoryFilterManager remoteRepositoryFilterManager) {
+ return new DefaultMetadataResolver(
+ repositoryEventDispatcher,
+ updateCheckManager,
+ repositoryConnectorProvider,
+ remoteRepositoryManager,
+ syncContextFactory,
+ offlineController,
+ remoteRepositoryFilterManager);
+ }
+
+ // Maven provided
+
+ protected Map getMetadataGeneratorFactories() {
+ // from maven-resolver-provider
+ HashMap result = new HashMap<>();
+ result.put(PluginsMetadataGeneratorFactory.NAME, new PluginsMetadataGeneratorFactory());
+ result.put(VersionsMetadataGeneratorFactory.NAME, new VersionsMetadataGeneratorFactory());
+ result.put(SnapshotMetadataGeneratorFactory.NAME, new SnapshotMetadataGeneratorFactory());
+ return result;
+ }
+
+ protected ArtifactDescriptorReader getArtifactDescriptorReader(
+ RemoteRepositoryManager remoteRepositoryManager,
+ VersionResolver versionResolver,
+ VersionRangeResolver versionRangeResolver,
+ ArtifactResolver artifactResolver,
+ ModelBuilder modelBuilder,
+ RepositoryEventDispatcher repositoryEventDispatcher,
+ ModelCacheFactory modelCacheFactory) {
+ // from maven-resolver-provider
+ return new DefaultArtifactDescriptorReader(
+ remoteRepositoryManager,
+ versionResolver,
+ versionRangeResolver,
+ artifactResolver,
+ modelBuilder,
+ repositoryEventDispatcher,
+ modelCacheFactory);
+ }
+
+ protected VersionResolver getVersionResolver(
+ MetadataResolver metadataResolver,
+ SyncContextFactory syncContextFactory,
+ RepositoryEventDispatcher repositoryEventDispatcher) {
+ // from maven-resolver-provider
+ return new DefaultVersionResolver(metadataResolver, syncContextFactory, repositoryEventDispatcher);
+ }
+
+ protected VersionRangeResolver getVersionRangeResolver(
+ MetadataResolver metadataResolver,
+ SyncContextFactory syncContextFactory,
+ RepositoryEventDispatcher repositoryEventDispatcher) {
+ // from maven-resolver-provider
+ return new DefaultVersionRangeResolver(metadataResolver, syncContextFactory, repositoryEventDispatcher);
+ }
+
+ protected ModelBuilder getModelBuilder() {
+ // from maven-model-builder
+ return new DefaultModelBuilderFactory().newInstance();
+ }
+
+ protected ModelCacheFactory getModelCacheFactory() {
+ // from maven-resolver-provider
+ return new DefaultModelCacheFactory();
+ }
+
+ @Override
+ public RepositorySystem get() {
+ FileProcessor fileProcessor = getFileProcessor();
+ TrackingFileManager trackingFileManager = getTrackingFileManager();
+ LocalPathComposer localPathComposer = getLocalPathComposer();
+ LocalPathPrefixComposerFactory localPathPrefixComposerFactory = getLocalPathPrefixComposerFactory();
+ RepositorySystemLifecycle repositorySystemLifecycle = getRepositorySystemLifecycle();
+ OfflineController offlineController = getOfflineController();
+ UpdatePolicyAnalyzer updatePolicyAnalyzer = getUpdatePolicyAnalyzer();
+ ChecksumPolicyProvider checksumPolicyProvider = getChecksumPolicyProvider();
+
+ UpdateCheckManager updateCheckManager = getUpdateCheckManager(trackingFileManager, updatePolicyAnalyzer);
+
+ Map namedLockFactories = getNamedLockFactories();
+ Map nameMappers = getNameMappers();
+ NamedLockFactoryAdapterFactory namedLockFactoryAdapterFactory =
+ getNamedLockFactoryAdapterFactory(namedLockFactories, nameMappers, repositorySystemLifecycle);
+ SyncContextFactory syncContextFactory = getSyncContextFactory(namedLockFactoryAdapterFactory);
+
+ Map checksumAlgorithmFactories = getChecksumAlgorithmFactories();
+ ChecksumAlgorithmFactorySelector checksumAlgorithmFactorySelector =
+ getChecksumAlgorithmFactorySelector(checksumAlgorithmFactories);
+
+ Map repositoryLayoutFactories =
+ getRepositoryLayoutFactories(checksumAlgorithmFactorySelector);
+ RepositoryLayoutProvider repositoryLayoutProvider = getRepositoryLayoutProvider(repositoryLayoutFactories);
+
+ LocalRepositoryProvider localRepositoryProvider =
+ getLocalRepositoryProvider(localPathComposer, trackingFileManager, localPathPrefixComposerFactory);
+
+ RemoteRepositoryManager remoteRepositoryManager =
+ getRemoteRepositoryManager(updatePolicyAnalyzer, checksumPolicyProvider);
+ Map remoteRepositoryFilterSources =
+ getRemoteRepositoryFilterSources(repositorySystemLifecycle, repositoryLayoutProvider);
+ RemoteRepositoryFilterManager remoteRepositoryFilterManager =
+ getRemoteRepositoryFilterManager(remoteRepositoryFilterSources);
+
+ Map repositoryListeners = getRepositoryListeners();
+ RepositoryEventDispatcher repositoryEventDispatcher = getRepositoryEventDispatcher(repositoryListeners);
+
+ Map trustedChecksumsSources =
+ getTrustedChecksumsSources(fileProcessor, localPathComposer, repositorySystemLifecycle);
+ Map providedChecksumsSources =
+ getProvidedChecksumsSources(trustedChecksumsSources);
+
+ Map checksumExtractors = getChecksumExtractors();
+ Map transporterFactories = getTransporterFactories(checksumExtractors);
+ TransporterProvider transporterProvider = getTransporterProvider(transporterFactories);
+
+ BasicRepositoryConnectorFactory basic = getBasicRepositoryConnectorFactory(
+ transporterProvider,
+ repositoryLayoutProvider,
+ checksumPolicyProvider,
+ fileProcessor,
+ providedChecksumsSources);
+ Map repositoryConnectorFactories = getRepositoryConnectorFactories(basic);
+ RepositoryConnectorProvider repositoryConnectorProvider =
+ getRepositoryConnectorProvider(repositoryConnectorFactories, remoteRepositoryFilterManager);
+
+ Map metadataGeneratorFactories = getMetadataGeneratorFactories();
+
+ Installer installer =
+ getInstaller(fileProcessor, repositoryEventDispatcher, metadataGeneratorFactories, syncContextFactory);
+ Deployer deployer = getDeployer(
+ fileProcessor,
+ repositoryEventDispatcher,
+ repositoryConnectorProvider,
+ remoteRepositoryManager,
+ updateCheckManager,
+ metadataGeneratorFactories,
+ syncContextFactory,
+ offlineController);
+
+ MetadataResolver metadataResolver = getMetadataResolver(
+ repositoryEventDispatcher,
+ updateCheckManager,
+ repositoryConnectorProvider,
+ remoteRepositoryManager,
+ syncContextFactory,
+ offlineController,
+ remoteRepositoryFilterManager);
+
+ VersionResolver versionResolver =
+ getVersionResolver(metadataResolver, syncContextFactory, repositoryEventDispatcher);
+ VersionRangeResolver versionRangeResolver =
+ getVersionRangeResolver(metadataResolver, syncContextFactory, repositoryEventDispatcher);
+
+ Map artifactResolverPostProcessors =
+ getArtifactResolverPostProcessors(checksumAlgorithmFactorySelector, trustedChecksumsSources);
+ ArtifactResolver artifactResolver = getArtifactResolver(
+ fileProcessor,
+ repositoryEventDispatcher,
+ versionResolver,
+ updateCheckManager,
+ repositoryConnectorProvider,
+ remoteRepositoryManager,
+ syncContextFactory,
+ offlineController,
+ artifactResolverPostProcessors,
+ remoteRepositoryFilterManager);
+
+ ModelBuilder modelBuilder = getModelBuilder();
+ ModelCacheFactory modelCacheFactory = getModelCacheFactory();
+
+ ArtifactDescriptorReader artifactDescriptorReader = getArtifactDescriptorReader(
+ remoteRepositoryManager,
+ versionResolver,
+ versionRangeResolver,
+ artifactResolver,
+ modelBuilder,
+ repositoryEventDispatcher,
+ modelCacheFactory);
+
+ Map dependencyCollectorDelegates = getDependencyCollectorDelegates(
+ remoteRepositoryManager, artifactDescriptorReader, versionRangeResolver);
+ DependencyCollector dependencyCollector = getDependencyCollector(dependencyCollectorDelegates);
+
+ return new DefaultRepositorySystem(
+ versionResolver,
+ versionRangeResolver,
+ artifactResolver,
+ metadataResolver,
+ artifactDescriptorReader,
+ dependencyCollector,
+ installer,
+ deployer,
+ localRepositoryProvider,
+ syncContextFactory,
+ remoteRepositoryManager,
+ repositorySystemLifecycle);
+ }
+}
diff --git a/maven-resolver-supplier/src/test/java/org/eclipse/aether/supplier/RepositorySystemSupplierTest.java b/maven-resolver-supplier/src/test/java/org/eclipse/aether/supplier/RepositorySystemSupplierTest.java
new file mode 100644
index 000000000..ffedd07ca
--- /dev/null
+++ b/maven-resolver-supplier/src/test/java/org/eclipse/aether/supplier/RepositorySystemSupplierTest.java
@@ -0,0 +1,68 @@
+/*
+ * 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.supplier;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
+import org.eclipse.aether.DefaultRepositorySystemSession;
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
+import org.eclipse.aether.repository.LocalRepository;
+import org.eclipse.aether.repository.RemoteRepository;
+import org.eclipse.aether.resolution.VersionRangeRequest;
+import org.eclipse.aether.resolution.VersionRangeResult;
+import org.eclipse.aether.version.Version;
+import org.junit.Test;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
+import static org.hamcrest.Matchers.hasSize;
+
+public class RepositorySystemSupplierTest {
+ private final RepositorySystemSupplier subject = new RepositorySystemSupplier();
+
+ public static DefaultRepositorySystemSession newRepositorySystemSession(RepositorySystem system) {
+ DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
+ LocalRepository localRepo = new LocalRepository("target/local-repo");
+ session.setLocalRepositoryManager(system.newLocalRepositoryManager(session, localRepo));
+ return session;
+ }
+
+ @Test
+ public void smoke() throws Exception {
+ RepositorySystem system = subject.get();
+ RepositorySystemSession session = newRepositorySystemSession(system);
+
+ Artifact artifact = new DefaultArtifact("org.apache.maven.resolver:maven-resolver-util:[0,)");
+ VersionRangeRequest rangeRequest = new VersionRangeRequest();
+ rangeRequest.setArtifact(artifact);
+ rangeRequest.setRepositories(Collections.singletonList(
+ new RemoteRepository.Builder("central", "default", "https://repo.maven.apache.org/maven2/").build()));
+ VersionRangeResult rangeResult = system.resolveVersionRange(session, rangeRequest);
+ List versions = rangeResult.getVersions();
+
+ // As of 2023-08-01, Maven Central has 33 versions of this artifact (and it will just grow)
+ assertThat(versions, hasSize(greaterThanOrEqualTo(33)));
+ System.out.println("Available versions " + versions);
+ }
+}
diff --git a/maven-resolver-test-util/pom.xml b/maven-resolver-test-util/pom.xml
index 6f3709712..5431cb1d7 100644
--- a/maven-resolver-test-util/pom.xml
+++ b/maven-resolver-test-util/pom.xml
@@ -23,7 +23,7 @@
org.apache.maven.resolver
maven-resolver
- 1.9.15-SNAPSHOT
+ 2.0.0-SNAPSHOT
maven-resolver-test-util
diff --git a/maven-resolver-test-util/src/main/java/org/eclipse/aether/internal/test/util/IniArtifactDataReader.java b/maven-resolver-test-util/src/main/java/org/eclipse/aether/internal/test/util/IniArtifactDataReader.java
index 3d0718dd2..c524acfb4 100644
--- a/maven-resolver-test-util/src/main/java/org/eclipse/aether/internal/test/util/IniArtifactDataReader.java
+++ b/maven-resolver-test-util/src/main/java/org/eclipse/aether/internal/test/util/IniArtifactDataReader.java
@@ -118,7 +118,7 @@ private ArtifactDescription parse(Reader reader) throws IOException {
String name = line.substring(1, line.length() - 1);
name = name.replace("-", "").toUpperCase(Locale.ENGLISH);
state = State.valueOf(name);
- sections.put(state, new ArrayList());
+ sections.put(state, new ArrayList<>());
} catch (IllegalArgumentException e) {
throw new IOException("unknown section: " + line);
}
diff --git a/maven-resolver-test-util/src/main/java/org/eclipse/aether/internal/test/util/TestFileUtils.java b/maven-resolver-test-util/src/main/java/org/eclipse/aether/internal/test/util/TestFileUtils.java
index acf175565..3eae72dba 100644
--- a/maven-resolver-test-util/src/main/java/org/eclipse/aether/internal/test/util/TestFileUtils.java
+++ b/maven-resolver-test-util/src/main/java/org/eclipse/aether/internal/test/util/TestFileUtils.java
@@ -240,6 +240,11 @@ public static void writeString(File file, String content) throws IOException {
writeBytes(file, content.getBytes(StandardCharsets.UTF_8), 1);
}
+ public static void writeString(File file, String content, long timestamp) throws IOException {
+ writeBytes(file, content.getBytes(StandardCharsets.UTF_8), 1);
+ file.setLastModified(timestamp);
+ }
+
public static void readProps(File file, Properties props) throws IOException {
FileInputStream fis = null;
try {
diff --git a/maven-resolver-transport-classpath/pom.xml b/maven-resolver-transport-classpath/pom.xml
index 03f1a5e68..f49877505 100644
--- a/maven-resolver-transport-classpath/pom.xml
+++ b/maven-resolver-transport-classpath/pom.xml
@@ -23,7 +23,7 @@
org.apache.maven.resolver
maven-resolver
- 1.9.15-SNAPSHOT
+ 2.0.0-SNAPSHOT
maven-resolver-transport-classpath
diff --git a/maven-resolver-transport-classpath/src/main/java/org/eclipse/aether/transport/classpath/ClasspathTransporterFactory.java b/maven-resolver-transport-classpath/src/main/java/org/eclipse/aether/transport/classpath/ClasspathTransporterFactory.java
index 772a28e53..c0a6c6133 100644
--- a/maven-resolver-transport-classpath/src/main/java/org/eclipse/aether/transport/classpath/ClasspathTransporterFactory.java
+++ b/maven-resolver-transport-classpath/src/main/java/org/eclipse/aether/transport/classpath/ClasspathTransporterFactory.java
@@ -36,8 +36,9 @@
*
* Note: Such repositories are read-only and uploads to them are generally not supported.
*/
-@Named("classpath")
+@Named(ClasspathTransporterFactory.NAME)
public final class ClasspathTransporterFactory implements TransporterFactory {
+ public static final String NAME = "classpath";
/**
* The key in the repository session's {@link RepositorySystemSession#getConfigProperties() configuration
diff --git a/maven-resolver-transport-file/pom.xml b/maven-resolver-transport-file/pom.xml
index 7ede9ce6d..89ce65de2 100644
--- a/maven-resolver-transport-file/pom.xml
+++ b/maven-resolver-transport-file/pom.xml
@@ -23,7 +23,7 @@
org.apache.maven.resolver
maven-resolver
- 1.9.15-SNAPSHOT
+ 2.0.0-SNAPSHOT
maven-resolver-transport-file
diff --git a/maven-resolver-transport-file/src/main/java/org/eclipse/aether/transport/file/FileTransporterFactory.java b/maven-resolver-transport-file/src/main/java/org/eclipse/aether/transport/file/FileTransporterFactory.java
index 1b4753295..168cb9734 100644
--- a/maven-resolver-transport-file/src/main/java/org/eclipse/aether/transport/file/FileTransporterFactory.java
+++ b/maven-resolver-transport-file/src/main/java/org/eclipse/aether/transport/file/FileTransporterFactory.java
@@ -31,8 +31,9 @@
/**
* A transporter factory for repositories using the {@code file:} protocol.
*/
-@Named("file")
+@Named(FileTransporterFactory.NAME)
public final class FileTransporterFactory implements TransporterFactory {
+ public static final String NAME = "file";
private float priority;
diff --git a/maven-resolver-transport-http/pom.xml b/maven-resolver-transport-http/pom.xml
index 82930f44a..928c8305b 100644
--- a/maven-resolver-transport-http/pom.xml
+++ b/maven-resolver-transport-http/pom.xml
@@ -23,7 +23,7 @@
org.apache.maven.resolver
maven-resolver
- 1.9.15-SNAPSHOT
+ 2.0.0-SNAPSHOT
maven-resolver-transport-http
@@ -34,20 +34,9 @@
org.apache.maven.resolver.transport.http
${Automatic-Module-Name}
- 9.4.51.v20230217
+ 9.4.52.v20230823
-
-
-
-
- commons-codec
- commons-codec
- 1.15
-
-
-
-
org.apache.maven.resolver
@@ -71,6 +60,11 @@
commons-logging
commons-logging