From 39b91eedd2e22dd8bda287170f0d1d8598975f8d Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Tue, 1 Aug 2023 13:33:06 +0200 Subject: [PATCH 01/23] [MRESOLVER-393] Transport HTTP should retain last-modified (#323) If sent by remote end. --- https://issues.apache.org/jira/browse/MRESOLVER-393 --- .../internal/test/util/TestFileUtils.java | 5 +++++ .../transport/http/HttpTransporter.java | 12 +++++++++++ .../transport/http/HttpTransporterTest.java | 20 +++++++++++++++++++ 3 files changed, 37 insertions(+) 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-http/src/main/java/org/eclipse/aether/transport/http/HttpTransporter.java b/maven-resolver-transport-http/src/main/java/org/eclipse/aether/transport/http/HttpTransporter.java index 3fba6a911..d1848cc95 100644 --- a/maven-resolver-transport-http/src/main/java/org/eclipse/aether/transport/http/HttpTransporter.java +++ b/maven-resolver-transport-http/src/main/java/org/eclipse/aether/transport/http/HttpTransporter.java @@ -31,6 +31,7 @@ import java.nio.charset.Charset; import java.nio.file.Files; import java.nio.file.StandardCopyOption; +import java.nio.file.attribute.FileTime; import java.util.Collections; import java.util.Date; import java.util.List; @@ -641,6 +642,17 @@ public void handle(CloseableHttpResponse response) throws IOException, TransferC task.setDataFile(dataFile); } } + if (task.getDataFile() != null) { + Header lastModifiedHeader = + response.getFirstHeader(HttpHeaders.LAST_MODIFIED); // note: Wagon also does first not last + if (lastModifiedHeader != null) { + Date lastModified = DateUtils.parseDate(lastModifiedHeader.getValue()); + if (lastModified != null) { + Files.setLastModifiedTime( + task.getDataFile().toPath(), FileTime.fromMillis(lastModified.getTime())); + } + } + } extractChecksums(response); } diff --git a/maven-resolver-transport-http/src/test/java/org/eclipse/aether/transport/http/HttpTransporterTest.java b/maven-resolver-transport-http/src/test/java/org/eclipse/aether/transport/http/HttpTransporterTest.java index 6341c1553..597b35787 100644 --- a/maven-resolver-transport-http/src/test/java/org/eclipse/aether/transport/http/HttpTransporterTest.java +++ b/maven-resolver-transport-http/src/test/java/org/eclipse/aether/transport/http/HttpTransporterTest.java @@ -102,6 +102,8 @@ private void newTransporter(String url) throws Exception { transporter = factory.newInstance(session, newRepo(url)); } + private static final long OLD_FILE_TIMESTAMP = 160660800000L; + @Before public void setUp() throws Exception { System.out.println("=== " + testName.getMethodName() + " ==="); @@ -110,6 +112,7 @@ public void setUp() throws Exception { repoDir = TestFileUtils.createTempDir(); TestFileUtils.writeString(new File(repoDir, "file.txt"), "test"); TestFileUtils.writeString(new File(repoDir, "dir/file.txt"), "test"); + TestFileUtils.writeString(new File(repoDir, "dir/oldFile.txt"), "oldTest", OLD_FILE_TIMESTAMP); TestFileUtils.writeString(new File(repoDir, "empty.txt"), ""); TestFileUtils.writeString(new File(repoDir, "some space.txt"), "space"); File resumable = new File(repoDir, "resume.txt"); @@ -293,6 +296,23 @@ public void testGet_ToFile() throws Exception { assertEquals("test", new String(listener.baos.toByteArray(), StandardCharsets.UTF_8)); } + @Test + public void testGet_ToFileTimestamp() throws Exception { + File file = TestFileUtils.createTempFile("failure"); + RecordingTransportListener listener = new RecordingTransportListener(); + GetTask task = new GetTask(URI.create("repo/dir/oldFile.txt")) + .setDataFile(file) + .setListener(listener); + transporter.get(task); + assertEquals("oldTest", TestFileUtils.readString(file)); + assertEquals(0L, listener.dataOffset); + assertEquals(7L, listener.dataLength); + assertEquals(1, listener.startedCount); + assertTrue("Count: " + listener.progressedCount, listener.progressedCount > 0); + assertEquals("oldTest", new String(listener.baos.toByteArray(), StandardCharsets.UTF_8)); + assertEquals(file.lastModified(), OLD_FILE_TIMESTAMP); + } + @Test public void testGet_EmptyResource() throws Exception { File file = TestFileUtils.createTempFile("failure"); From c764d5d796b61d6b0d351b00c1d5473edee7fef9 Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Tue, 1 Aug 2023 13:51:25 +0200 Subject: [PATCH 02/23] [MRESOLVER-386] Make all injected ctors public, deprecate def ctors (#321) All injection points are public and deprecate all def ctors (where ctor injection used). --- https://issues.apache.org/jira/browse/MRESOLVER-386 --- .../connector/basic/BasicRepositoryConnectorFactory.java | 3 ++- .../eclipse/aether/internal/impl/DefaultArtifactResolver.java | 3 ++- .../org/eclipse/aether/internal/impl/DefaultDeployer.java | 3 ++- .../org/eclipse/aether/internal/impl/DefaultInstaller.java | 3 ++- .../aether/internal/impl/DefaultLocalRepositoryProvider.java | 3 ++- .../eclipse/aether/internal/impl/DefaultMetadataResolver.java | 3 ++- .../aether/internal/impl/DefaultRemoteRepositoryManager.java | 3 ++- .../internal/impl/DefaultRepositoryConnectorProvider.java | 3 ++- .../internal/impl/DefaultRepositoryEventDispatcher.java | 3 ++- .../aether/internal/impl/DefaultRepositoryLayoutProvider.java | 3 ++- .../eclipse/aether/internal/impl/DefaultRepositorySystem.java | 3 ++- .../aether/internal/impl/DefaultTransporterProvider.java | 3 ++- .../aether/internal/impl/DefaultUpdateCheckManager.java | 4 +++- .../internal/impl/EnhancedLocalRepositoryManagerFactory.java | 1 + .../internal/impl/SimpleLocalRepositoryManagerFactory.java | 1 + .../internal/impl/collect/bf/BfDependencyCollector.java | 2 +- .../internal/impl/collect/df/DfDependencyCollector.java | 2 +- .../impl/synccontext/legacy/DefaultSyncContextFactory.java | 1 + .../aether/transport/wagon/WagonTransporterFactory.java | 3 ++- 19 files changed, 34 insertions(+), 16 deletions(-) diff --git a/maven-resolver-connector-basic/src/main/java/org/eclipse/aether/connector/basic/BasicRepositoryConnectorFactory.java b/maven-resolver-connector-basic/src/main/java/org/eclipse/aether/connector/basic/BasicRepositoryConnectorFactory.java index 8fa86edcb..76dc3116d 100644 --- a/maven-resolver-connector-basic/src/main/java/org/eclipse/aether/connector/basic/BasicRepositoryConnectorFactory.java +++ b/maven-resolver-connector-basic/src/main/java/org/eclipse/aether/connector/basic/BasicRepositoryConnectorFactory.java @@ -63,12 +63,13 @@ public final class BasicRepositoryConnectorFactory implements RepositoryConnecto * clients, the new factory needs to be configured via its various mutators before first use or runtime errors will * occur. */ + @Deprecated public BasicRepositoryConnectorFactory() { // enables default constructor } @Inject - BasicRepositoryConnectorFactory( + public BasicRepositoryConnectorFactory( TransporterProvider transporterProvider, RepositoryLayoutProvider layoutProvider, ChecksumPolicyProvider checksumPolicyProvider, diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultArtifactResolver.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultArtifactResolver.java index a77ab9064..044302461 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultArtifactResolver.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultArtifactResolver.java @@ -125,13 +125,14 @@ public class DefaultArtifactResolver implements ArtifactResolver, Service { private RemoteRepositoryFilterManager remoteRepositoryFilterManager; + @Deprecated public DefaultArtifactResolver() { // enables default constructor } @SuppressWarnings("checkstyle:parameternumber") @Inject - DefaultArtifactResolver( + public DefaultArtifactResolver( FileProcessor fileProcessor, RepositoryEventDispatcher repositoryEventDispatcher, VersionResolver versionResolver, diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultDeployer.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultDeployer.java index be9df02c4..e451fa1a4 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultDeployer.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultDeployer.java @@ -97,13 +97,14 @@ public class DefaultDeployer implements Deployer, Service { private OfflineController offlineController; + @Deprecated public DefaultDeployer() { // enables default constructor } @SuppressWarnings("checkstyle:parameternumber") @Inject - DefaultDeployer( + public DefaultDeployer( FileProcessor fileProcessor, RepositoryEventDispatcher repositoryEventDispatcher, RepositoryConnectorProvider repositoryConnectorProvider, diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultInstaller.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultInstaller.java index 6ce59e6bb..c30f75a2e 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultInstaller.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultInstaller.java @@ -75,12 +75,13 @@ public class DefaultInstaller implements Installer, Service { private SyncContextFactory syncContextFactory; + @Deprecated public DefaultInstaller() { // enables default constructor } @Inject - DefaultInstaller( + public DefaultInstaller( FileProcessor fileProcessor, RepositoryEventDispatcher repositoryEventDispatcher, Set metadataFactories, diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultLocalRepositoryProvider.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultLocalRepositoryProvider.java index 201b79348..6be859f68 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultLocalRepositoryProvider.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultLocalRepositoryProvider.java @@ -50,12 +50,13 @@ public class DefaultLocalRepositoryProvider implements LocalRepositoryProvider, private Collection managerFactories = new ArrayList<>(); + @Deprecated public DefaultLocalRepositoryProvider() { // enables default constructor } @Inject - DefaultLocalRepositoryProvider(Set factories) { + public DefaultLocalRepositoryProvider(Set factories) { setLocalRepositoryManagerFactories(factories); } diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultMetadataResolver.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultMetadataResolver.java index a077d7ac3..e28dd75bf 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultMetadataResolver.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultMetadataResolver.java @@ -92,12 +92,13 @@ public class DefaultMetadataResolver implements MetadataResolver, Service { private RemoteRepositoryFilterManager remoteRepositoryFilterManager; + @Deprecated public DefaultMetadataResolver() { // enables default constructor } @Inject - DefaultMetadataResolver( + public DefaultMetadataResolver( RepositoryEventDispatcher repositoryEventDispatcher, UpdateCheckManager updateCheckManager, RepositoryConnectorProvider repositoryConnectorProvider, diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRemoteRepositoryManager.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRemoteRepositoryManager.java index 9a297555c..9f8471ee4 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRemoteRepositoryManager.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRemoteRepositoryManager.java @@ -83,12 +83,13 @@ public int hashCode() { private ChecksumPolicyProvider checksumPolicyProvider; + @Deprecated public DefaultRemoteRepositoryManager() { // enables default constructor } @Inject - DefaultRemoteRepositoryManager( + public DefaultRemoteRepositoryManager( UpdatePolicyAnalyzer updatePolicyAnalyzer, ChecksumPolicyProvider checksumPolicyProvider) { setUpdatePolicyAnalyzer(updatePolicyAnalyzer); setChecksumPolicyProvider(checksumPolicyProvider); diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRepositoryConnectorProvider.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRepositoryConnectorProvider.java index 1f94cb2ef..b058eb0e0 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRepositoryConnectorProvider.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRepositoryConnectorProvider.java @@ -57,12 +57,13 @@ public class DefaultRepositoryConnectorProvider implements RepositoryConnectorPr private RemoteRepositoryFilterManager remoteRepositoryFilterManager; + @Deprecated public DefaultRepositoryConnectorProvider() { // enables default constructor } @Inject - DefaultRepositoryConnectorProvider( + public DefaultRepositoryConnectorProvider( Set connectorFactories, RemoteRepositoryFilterManager remoteRepositoryFilterManager) { setRepositoryConnectorFactories(connectorFactories); diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRepositoryEventDispatcher.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRepositoryEventDispatcher.java index 31b15292d..f603f1c0a 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRepositoryEventDispatcher.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRepositoryEventDispatcher.java @@ -46,12 +46,13 @@ public class DefaultRepositoryEventDispatcher implements RepositoryEventDispatch private Collection listeners = new ArrayList<>(); + @Deprecated public DefaultRepositoryEventDispatcher() { // enables no-arg constructor } @Inject - DefaultRepositoryEventDispatcher(Set listeners) { + public DefaultRepositoryEventDispatcher(Set listeners) { setRepositoryListeners(listeners); } diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRepositoryLayoutProvider.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRepositoryLayoutProvider.java index f555c684f..52cc6beaf 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRepositoryLayoutProvider.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRepositoryLayoutProvider.java @@ -50,12 +50,13 @@ public final class DefaultRepositoryLayoutProvider implements RepositoryLayoutPr private Collection factories = new ArrayList<>(); + @Deprecated public DefaultRepositoryLayoutProvider() { // enables default constructor } @Inject - DefaultRepositoryLayoutProvider(Set layoutFactories) { + public DefaultRepositoryLayoutProvider(Set layoutFactories) { setRepositoryLayoutFactories(layoutFactories); } diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRepositorySystem.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRepositorySystem.java index 4c3d37470..8477d5bb3 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRepositorySystem.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRepositorySystem.java @@ -117,6 +117,7 @@ public class DefaultRepositorySystem implements RepositorySystem, Service { private RepositorySystemLifecycle repositorySystemLifecycle; + @Deprecated public DefaultRepositorySystem() { // enables default constructor this.shutdown = new AtomicBoolean(false); @@ -124,7 +125,7 @@ public DefaultRepositorySystem() { @SuppressWarnings("checkstyle:parameternumber") @Inject - DefaultRepositorySystem( + public DefaultRepositorySystem( VersionResolver versionResolver, VersionRangeResolver versionRangeResolver, ArtifactResolver artifactResolver, diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultTransporterProvider.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultTransporterProvider.java index f7d10b19d..dd6823e96 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultTransporterProvider.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultTransporterProvider.java @@ -50,12 +50,13 @@ public final class DefaultTransporterProvider implements TransporterProvider, Se private Collection factories = new ArrayList<>(); + @Deprecated public DefaultTransporterProvider() { // enables default constructor } @Inject - DefaultTransporterProvider(Set transporterFactories) { + public DefaultTransporterProvider(Set transporterFactories) { setTransporterFactories(transporterFactories); } diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultUpdateCheckManager.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultUpdateCheckManager.java index 367bc2b2c..50a960bfa 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultUpdateCheckManager.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultUpdateCheckManager.java @@ -106,12 +106,14 @@ public String toString() { */ private static final long TS_UNKNOWN = 1L; + @Deprecated public DefaultUpdateCheckManager() { // default ctor for ServiceLocator } @Inject - DefaultUpdateCheckManager(TrackingFileManager trackingFileManager, UpdatePolicyAnalyzer updatePolicyAnalyzer) { + public DefaultUpdateCheckManager( + TrackingFileManager trackingFileManager, UpdatePolicyAnalyzer updatePolicyAnalyzer) { setTrackingFileManager(trackingFileManager); setUpdatePolicyAnalyzer(updatePolicyAnalyzer); } diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/EnhancedLocalRepositoryManagerFactory.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/EnhancedLocalRepositoryManagerFactory.java index 44b7f6ba4..ec1c5583c 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/EnhancedLocalRepositoryManagerFactory.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/EnhancedLocalRepositoryManagerFactory.java @@ -55,6 +55,7 @@ public class EnhancedLocalRepositoryManagerFactory implements LocalRepositoryMan private LocalPathPrefixComposerFactory localPathPrefixComposerFactory; + @Deprecated public EnhancedLocalRepositoryManagerFactory() { // no arg ctor for ServiceLocator } diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/SimpleLocalRepositoryManagerFactory.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/SimpleLocalRepositoryManagerFactory.java index 40b923408..1fe6d19eb 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/SimpleLocalRepositoryManagerFactory.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/SimpleLocalRepositoryManagerFactory.java @@ -42,6 +42,7 @@ public class SimpleLocalRepositoryManagerFactory implements LocalRepositoryManag private LocalPathComposer localPathComposer; + @Deprecated public SimpleLocalRepositoryManagerFactory() { // enable no-arg constructor this.localPathComposer = new DefaultLocalPathComposer(); // maven UTs needs this diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/collect/bf/BfDependencyCollector.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/collect/bf/BfDependencyCollector.java index 56e6704e8..68a417579 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/collect/bf/BfDependencyCollector.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/collect/bf/BfDependencyCollector.java @@ -121,7 +121,7 @@ public BfDependencyCollector() { } @Inject - BfDependencyCollector( + public BfDependencyCollector( RemoteRepositoryManager remoteRepositoryManager, ArtifactDescriptorReader artifactDescriptorReader, VersionRangeResolver versionRangeResolver) { diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/collect/df/DfDependencyCollector.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/collect/df/DfDependencyCollector.java index f6d9900f4..5948d4fd8 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/collect/df/DfDependencyCollector.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/collect/df/DfDependencyCollector.java @@ -79,7 +79,7 @@ public DfDependencyCollector() { } @Inject - DfDependencyCollector( + public DfDependencyCollector( RemoteRepositoryManager remoteRepositoryManager, ArtifactDescriptorReader artifactDescriptorReader, VersionRangeResolver versionRangeResolver) { diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/legacy/DefaultSyncContextFactory.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/legacy/DefaultSyncContextFactory.java index 86e2d9666..71b7f09aa 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/legacy/DefaultSyncContextFactory.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/legacy/DefaultSyncContextFactory.java @@ -43,6 +43,7 @@ public final class DefaultSyncContextFactory implements org.eclipse.aether.impl.SyncContextFactory, Service { private SyncContextFactory delegate; + @Deprecated public DefaultSyncContextFactory() { // default ctor for ServiceLocator } diff --git a/maven-resolver-transport-wagon/src/main/java/org/eclipse/aether/transport/wagon/WagonTransporterFactory.java b/maven-resolver-transport-wagon/src/main/java/org/eclipse/aether/transport/wagon/WagonTransporterFactory.java index 5c6ebabeb..bdac5e9d8 100644 --- a/maven-resolver-transport-wagon/src/main/java/org/eclipse/aether/transport/wagon/WagonTransporterFactory.java +++ b/maven-resolver-transport-wagon/src/main/java/org/eclipse/aether/transport/wagon/WagonTransporterFactory.java @@ -50,12 +50,13 @@ public final class WagonTransporterFactory implements TransporterFactory, Servic * by clients, the new factory needs to be configured via its various mutators before first use or runtime errors * will occur. */ + @Deprecated public WagonTransporterFactory() { // enables default constructor } @Inject - WagonTransporterFactory(WagonProvider wagonProvider, WagonConfigurator wagonConfigurator) { + public WagonTransporterFactory(WagonProvider wagonProvider, WagonConfigurator wagonConfigurator) { setWagonProvider(wagonProvider); setWagonConfigurator(wagonConfigurator); } From 8f834852834417427030c4955e1809ce0c59e678 Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Tue, 1 Aug 2023 13:51:45 +0200 Subject: [PATCH 03/23] [MRESOLVER-388] Proper overide of commons-codec (#320) --- https://issues.apache.org/jira/browse/MRESOLVER-388 --- maven-resolver-transport-http/pom.xml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/maven-resolver-transport-http/pom.xml b/maven-resolver-transport-http/pom.xml index 82930f44a..6899746f9 100644 --- a/maven-resolver-transport-http/pom.xml +++ b/maven-resolver-transport-http/pom.xml @@ -37,17 +37,6 @@ 9.4.51.v20230217 - - - - - commons-codec - commons-codec - 1.15 - - - - org.apache.maven.resolver @@ -71,6 +60,11 @@ commons-logging commons-logging + + + commons-codec + commons-codec + @@ -78,6 +72,12 @@ httpcore 4.4.16 + + commons-codec + commons-codec + 1.15 + runtime + org.slf4j jcl-over-slf4j From 249c94ce67fd5935d7affc13864106bcac3123a2 Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Wed, 2 Aug 2023 15:37:04 +0200 Subject: [PATCH 04/23] [MRESOLVER-387] New RepositorySystem supplier (#319) Added a new module that provides RepositorySystem supplier. To complete RepositorySystem instance, one needs some of Maven dependencies as well, hence the new module. The supplier provides non intrusive lightweight replacement for ServiceLocator. Changes: * new module with supplier * add new booter to demos using supplier (and make it default, instead of SL) * align Maven version used across "demo" and new module (fix demo guice module for that) * update javadoc of deprecated SL --- https://issues.apache.org/jira/browse/MRESOLVER-387 --- .../maven-resolver-demo-snippets/pom.xml | 4 + .../examples/guice/DemoResolverModule.java | 7 + .../SupplierRepositorySystemFactory.java | 31 + .../maven/resolver/examples/util/Booter.java | 7 +- .../examples/AllResolverDemosTest.java | 5 + maven-resolver-demos/pom.xml | 5 - .../aether/impl/DefaultServiceLocator.java | 3 +- .../org/eclipse/aether/impl/package-info.java | 2 +- .../eclipse/aether/spi/locator/Service.java | 3 +- .../aether/spi/locator/ServiceLocator.java | 3 +- .../aether/spi/locator/package-info.java | 5 +- maven-resolver-supplier/README.md | 56 ++ maven-resolver-supplier/pom.xml | 148 ++++ .../supplier/RepositorySystemSupplier.java | 645 ++++++++++++++++++ .../RepositorySystemSupplierTest.java | 68 ++ pom.xml | 8 + 16 files changed, 988 insertions(+), 12 deletions(-) create mode 100644 maven-resolver-demos/maven-resolver-demo-snippets/src/main/java/org/apache/maven/resolver/examples/supplier/SupplierRepositorySystemFactory.java create mode 100644 maven-resolver-supplier/README.md create mode 100644 maven-resolver-supplier/pom.xml create mode 100644 maven-resolver-supplier/src/main/java/org/eclipse/aether/supplier/RepositorySystemSupplier.java create mode 100644 maven-resolver-supplier/src/test/java/org/eclipse/aether/supplier/RepositorySystemSupplierTest.java diff --git a/maven-resolver-demos/maven-resolver-demo-snippets/pom.xml b/maven-resolver-demos/maven-resolver-demo-snippets/pom.xml index 7364a4a92..f4c34e50a 100644 --- a/maven-resolver-demos/maven-resolver-demo-snippets/pom.xml +++ b/maven-resolver-demos/maven-resolver-demo-snippets/pom.xml @@ -65,6 +65,10 @@ org.apache.maven.resolver maven-resolver-transport-http + + org.apache.maven.resolver + maven-resolver-supplier + org.apache.maven maven-resolver-provider diff --git a/maven-resolver-demos/maven-resolver-demo-snippets/src/main/java/org/apache/maven/resolver/examples/guice/DemoResolverModule.java b/maven-resolver-demos/maven-resolver-demo-snippets/src/main/java/org/apache/maven/resolver/examples/guice/DemoResolverModule.java index c382e7480..155d0ef51 100644 --- a/maven-resolver-demos/maven-resolver-demo-snippets/src/main/java/org/apache/maven/resolver/examples/guice/DemoResolverModule.java +++ b/maven-resolver-demos/maven-resolver-demo-snippets/src/main/java/org/apache/maven/resolver/examples/guice/DemoResolverModule.java @@ -32,8 +32,10 @@ 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.SnapshotMetadataGeneratorFactory; import org.apache.maven.repository.internal.VersionsMetadataGeneratorFactory; import org.eclipse.aether.connector.basic.BasicRepositoryConnectorFactory; @@ -142,4 +144,9 @@ Set provideMetadataGeneratorFactories( ModelBuilder provideModelBuilder() { return new DefaultModelBuilderFactory().newInstance(); } + + @Provides + ModelCacheFactory provideModelCacheFactory() { + return new DefaultModelCacheFactory(); + } } diff --git a/maven-resolver-demos/maven-resolver-demo-snippets/src/main/java/org/apache/maven/resolver/examples/supplier/SupplierRepositorySystemFactory.java b/maven-resolver-demos/maven-resolver-demo-snippets/src/main/java/org/apache/maven/resolver/examples/supplier/SupplierRepositorySystemFactory.java new file mode 100644 index 000000000..a649322bd --- /dev/null +++ b/maven-resolver-demos/maven-resolver-demo-snippets/src/main/java/org/apache/maven/resolver/examples/supplier/SupplierRepositorySystemFactory.java @@ -0,0 +1,31 @@ +/* + * 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.resolver.examples.supplier; + +import org.eclipse.aether.RepositorySystem; +import org.eclipse.aether.supplier.RepositorySystemSupplier; + +/** + * A factory for repository system instances that employs Maven Artifact Resolver's provided supplier. + */ +public class SupplierRepositorySystemFactory { + public static RepositorySystem newRepositorySystem() { + return new RepositorySystemSupplier().get(); + } +} diff --git a/maven-resolver-demos/maven-resolver-demo-snippets/src/main/java/org/apache/maven/resolver/examples/util/Booter.java b/maven-resolver-demos/maven-resolver-demo-snippets/src/main/java/org/apache/maven/resolver/examples/util/Booter.java index 2744650b6..e650786d6 100644 --- a/maven-resolver-demos/maven-resolver-demo-snippets/src/main/java/org/apache/maven/resolver/examples/util/Booter.java +++ b/maven-resolver-demos/maven-resolver-demo-snippets/src/main/java/org/apache/maven/resolver/examples/util/Booter.java @@ -36,6 +36,8 @@ public class Booter { public static final String SERVICE_LOCATOR = "serviceLocator"; + public static final String SUPPLIER = "supplier"; + public static final String GUICE = "guice"; public static final String SISU = "sisu"; @@ -44,7 +46,7 @@ public class Booter { public static String selectFactory(String[] args) { if (args == null || args.length == 0) { - return SERVICE_LOCATOR; + return SUPPLIER; } else { return args[0]; } @@ -54,6 +56,9 @@ public static RepositorySystem newRepositorySystem(final String factory) { switch (factory) { case SERVICE_LOCATOR: return org.apache.maven.resolver.examples.manual.ManualRepositorySystemFactory.newRepositorySystem(); + case SUPPLIER: + return org.apache.maven.resolver.examples.supplier.SupplierRepositorySystemFactory + .newRepositorySystem(); case GUICE: return org.apache.maven.resolver.examples.guice.GuiceRepositorySystemFactory.newRepositorySystem(); case SISU: diff --git a/maven-resolver-demos/maven-resolver-demo-snippets/src/test/java/org/apache/maven/resolver/examples/AllResolverDemosTest.java b/maven-resolver-demos/maven-resolver-demo-snippets/src/test/java/org/apache/maven/resolver/examples/AllResolverDemosTest.java index 40024aec4..ef31f936b 100644 --- a/maven-resolver-demos/maven-resolver-demo-snippets/src/test/java/org/apache/maven/resolver/examples/AllResolverDemosTest.java +++ b/maven-resolver-demos/maven-resolver-demo-snippets/src/test/java/org/apache/maven/resolver/examples/AllResolverDemosTest.java @@ -30,6 +30,11 @@ public void serviceLocator() throws Exception { AllResolverDemos.main(new String[] {Booter.SERVICE_LOCATOR}); } + @Test + public void supplier() throws Exception { + AllResolverDemos.main(new String[] {Booter.SUPPLIER}); + } + @Test public void guice() throws Exception { AllResolverDemos.main(new String[] {Booter.GUICE}); diff --git a/maven-resolver-demos/pom.xml b/maven-resolver-demos/pom.xml index ebbcc92b5..49a7a267a 100644 --- a/maven-resolver-demos/pom.xml +++ b/maven-resolver-demos/pom.xml @@ -37,11 +37,6 @@ maven-resolver-demo-maven-plugin - - - 3.8.7 - - diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/impl/DefaultServiceLocator.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/impl/DefaultServiceLocator.java index 0c8f7598f..4f96f227f 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/impl/DefaultServiceLocator.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/impl/DefaultServiceLocator.java @@ -87,7 +87,8 @@ * Note: This class is not thread-safe. Clients are expected to create the service locator and the repository * system on a single thread. * - * @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 final class DefaultServiceLocator implements ServiceLocator { diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/impl/package-info.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/impl/package-info.java index 7c7344f06..7c61005e1 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/impl/package-info.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/impl/package-info.java @@ -18,7 +18,7 @@ * under the License. */ /** - * The provisional interfaces defining the various sub components that implement the repository system. Aether Core + * The provisional interfaces defining the various subcomponents that implement the repository system. Aether Core * provides stock implementations for most of these components but not all. To obtain a complete/runnable repository * system, the application needs to provide implementations of the following component contracts: * {@link org.eclipse.aether.impl.ArtifactDescriptorReader}, {@link org.eclipse.aether.impl.VersionResolver}, 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/README.md b/maven-resolver-supplier/README.md new file mode 100644 index 000000000..6b2a023b9 --- /dev/null +++ b/maven-resolver-supplier/README.md @@ -0,0 +1,56 @@ + + +# Maven Resolver Supplier + +This simple module serves the purpose to "bootstrap" resolver when there is no desire to use +[Eclipse Sisu](https://eclipse.dev/sisu/). It provides one simple class +`org.eclipse.aether.supplier.RepositorySystemSupplier` that implements `Supplier` +and supplies ready-to-use `RepositorySystem` instances. + +The supplier class is written in such way, to allow easy customization if needed: just extend the class and override +method one need (all methods are protected). + +Consumer/users of this module **must provide SLF4J backend**. Resolver uses `slf4j-api` for logging purposes, but this +module does NOT provide any backend for it. It is the consumer/user obligation to provide one at runtime. + +Version of `maven-resolver-supplier` artifact used **must be strictly aligned** with other Resolver artifacts +on classpath. + +By default, "full resolver experience" is provided: +* for connector, the connector-basic is provided +* for transport the two transport-file and transport-http implementations are provided. If Wagon is needed, add + transport-wagon as dependency, and customize `RepositorySystemSupplier` to include it. This makes it available, but + NOT used yet! To use it, you still need to configure resolver to favor Wagon over native HTTP. + +# Resolver configuration + +The supplier will provide only a "vanilla" instance. To configure resolver, use session user (or +configuration) properties, when constructing session. All the configuration options are available as +[listed here](https://maven.apache.org/resolver/configuration.html). + +# Extending Resolver + +Extending supplied resolver is simple, and basically requires same three steps for whatever extra you want to include +(like Wagon transport, distributed locking, etc). + +First, you need to include needed module (with transitive deps) to your dependencies. + +Second, you need to customize `RepositorySystemSupplier` to make new components (`WagonTransporterFactory`, or +distributed lock factories) available. + +Third, you need to configure session (via user of config properties) to make Resolver use newly added components. \ No newline at end of file diff --git a/maven-resolver-supplier/pom.xml b/maven-resolver-supplier/pom.xml new file mode 100644 index 000000000..d652bb01f --- /dev/null +++ b/maven-resolver-supplier/pom.xml @@ -0,0 +1,148 @@ + + + + 4.0.0 + + + org.apache.maven.resolver + maven-resolver + 1.9.15-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..f20023352 --- /dev/null +++ b/maven-resolver-supplier/src/main/java/org/eclipse/aether/supplier/RepositorySystemSupplier.java @@ -0,0 +1,645 @@ +/* + * 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("maven2", 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("file", new FileTransporterFactory()); + result.put("http", 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("basic", 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("plugins", new PluginsMetadataGeneratorFactory()); + result.put("versions", new VersionsMetadataGeneratorFactory()); + result.put("snapshot", 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 + DefaultArtifactDescriptorReader result = new DefaultArtifactDescriptorReader(); + result.setRemoteRepositoryManager(remoteRepositoryManager); + result.setVersionResolver(versionResolver); + result.setVersionRangeResolver(versionRangeResolver); + result.setArtifactResolver(artifactResolver); + result.setModelBuilder(modelBuilder); + result.setRepositoryEventDispatcher(repositoryEventDispatcher); + result.setModelCacheFactory(modelCacheFactory); + return result; + } + + protected VersionResolver getVersionResolver( + MetadataResolver metadataResolver, + SyncContextFactory syncContextFactory, + RepositoryEventDispatcher repositoryEventDispatcher) { + // from maven-resolver-provider + DefaultVersionResolver result = new DefaultVersionResolver(); + result.setMetadataResolver(metadataResolver); + result.setSyncContextFactory(syncContextFactory); + result.setRepositoryEventDispatcher(repositoryEventDispatcher); + return result; + } + + protected VersionRangeResolver getVersionRangeResolver( + MetadataResolver metadataResolver, + SyncContextFactory syncContextFactory, + RepositoryEventDispatcher repositoryEventDispatcher) { + // from maven-resolver-provider + DefaultVersionRangeResolver result = new DefaultVersionRangeResolver(); + result.setMetadataResolver(metadataResolver); + result.setSyncContextFactory(syncContextFactory); + result.setRepositoryEventDispatcher(repositoryEventDispatcher); + return result; + } + + 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/pom.xml b/pom.xml index c96433022..e6a65fcbf 100644 --- a/pom.xml +++ b/pom.xml @@ -58,6 +58,7 @@ maven-resolver-transport-file maven-resolver-transport-http maven-resolver-transport-wagon + maven-resolver-supplier maven-resolver-demos @@ -91,6 +92,8 @@ 0.3.5 5.1.0 1.7.36 + + 3.9.3 [3.8.7,) [1.8.0-362,) 2023-07-20T09:56:17Z @@ -148,6 +151,11 @@ maven-resolver-transport-wagon ${project.version} + + org.apache.maven.resolver + maven-resolver-supplier + ${project.version} + org.apache.maven.resolver maven-resolver-test-util From 794337168297344e1507a0d289a27e91bc5912ed Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Fri, 4 Aug 2023 13:32:27 +0200 Subject: [PATCH 05/23] [MRESOLVER-395] Update dependencies, tidy up (#324) Update dependencies: * hazelcast 5.3.1 * redisson 3.23.2 * commons-codec 1.16.0 * maven (in demos and supplier) 3.9.4 Also, minor, but: * remove redundant plugin assembly plugin version (redisson module, is defined in parent) * fix demo plugin prerequisite, align with minimal maven build version --- https://issues.apache.org/jira/browse/MRESOLVER-395 --- maven-resolver-demos/maven-resolver-demo-maven-plugin/pom.xml | 2 +- maven-resolver-named-locks-hazelcast/pom.xml | 2 +- maven-resolver-named-locks-redisson/pom.xml | 3 +-- maven-resolver-transport-http/pom.xml | 2 +- pom.xml | 2 +- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/maven-resolver-demos/maven-resolver-demo-maven-plugin/pom.xml b/maven-resolver-demos/maven-resolver-demo-maven-plugin/pom.xml index 00406c549..8af0caebb 100644 --- a/maven-resolver-demos/maven-resolver-demo-maven-plugin/pom.xml +++ b/maven-resolver-demos/maven-resolver-demo-maven-plugin/pom.xml @@ -33,7 +33,7 @@ A simple Maven plugin using Maven Artifact Resolver with Maven repositories. - ${mavenVersion} + ${minimalMavenBuildVersion} diff --git a/maven-resolver-named-locks-hazelcast/pom.xml b/maven-resolver-named-locks-hazelcast/pom.xml index 563b49d65..bff963b1a 100644 --- a/maven-resolver-named-locks-hazelcast/pom.xml +++ b/maven-resolver-named-locks-hazelcast/pom.xml @@ -50,7 +50,7 @@ com.hazelcast hazelcast - 5.3.0 + 5.3.1 javax.inject diff --git a/maven-resolver-named-locks-redisson/pom.xml b/maven-resolver-named-locks-redisson/pom.xml index cf5cad489..1d09b4ae0 100644 --- a/maven-resolver-named-locks-redisson/pom.xml +++ b/maven-resolver-named-locks-redisson/pom.xml @@ -50,7 +50,7 @@ org.redisson redisson - 3.21.3 + 3.23.2 org.slf4j @@ -135,7 +135,6 @@ org.apache.maven.plugins maven-assembly-plugin - 3.5.0 bundle diff --git a/maven-resolver-transport-http/pom.xml b/maven-resolver-transport-http/pom.xml index 6899746f9..875d5adb1 100644 --- a/maven-resolver-transport-http/pom.xml +++ b/maven-resolver-transport-http/pom.xml @@ -75,7 +75,7 @@ commons-codec commons-codec - 1.15 + 1.16.0 runtime diff --git a/pom.xml b/pom.xml index e6a65fcbf..a9f659eb0 100644 --- a/pom.xml +++ b/pom.xml @@ -93,7 +93,7 @@ 5.1.0 1.7.36 - 3.9.3 + 3.9.4 [3.8.7,) [1.8.0-362,) 2023-07-20T09:56:17Z From 2ff8cb8a105fe6fd4f675acf08061eab5c102496 Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Fri, 4 Aug 2023 14:17:34 +0200 Subject: [PATCH 06/23] Add new site page "Third-party Integrations" Where new supplier is described. --- maven-resolver-supplier/README.md | 56 --------------- src/site/markdown/third-party-integrations.md | 72 +++++++++++++++++++ src/site/site.xml | 1 + 3 files changed, 73 insertions(+), 56 deletions(-) delete mode 100644 maven-resolver-supplier/README.md create mode 100644 src/site/markdown/third-party-integrations.md diff --git a/maven-resolver-supplier/README.md b/maven-resolver-supplier/README.md deleted file mode 100644 index 6b2a023b9..000000000 --- a/maven-resolver-supplier/README.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Maven Resolver Supplier - -This simple module serves the purpose to "bootstrap" resolver when there is no desire to use -[Eclipse Sisu](https://eclipse.dev/sisu/). It provides one simple class -`org.eclipse.aether.supplier.RepositorySystemSupplier` that implements `Supplier` -and supplies ready-to-use `RepositorySystem` instances. - -The supplier class is written in such way, to allow easy customization if needed: just extend the class and override -method one need (all methods are protected). - -Consumer/users of this module **must provide SLF4J backend**. Resolver uses `slf4j-api` for logging purposes, but this -module does NOT provide any backend for it. It is the consumer/user obligation to provide one at runtime. - -Version of `maven-resolver-supplier` artifact used **must be strictly aligned** with other Resolver artifacts -on classpath. - -By default, "full resolver experience" is provided: -* for connector, the connector-basic is provided -* for transport the two transport-file and transport-http implementations are provided. If Wagon is needed, add - transport-wagon as dependency, and customize `RepositorySystemSupplier` to include it. This makes it available, but - NOT used yet! To use it, you still need to configure resolver to favor Wagon over native HTTP. - -# Resolver configuration - -The supplier will provide only a "vanilla" instance. To configure resolver, use session user (or -configuration) properties, when constructing session. All the configuration options are available as -[listed here](https://maven.apache.org/resolver/configuration.html). - -# Extending Resolver - -Extending supplied resolver is simple, and basically requires same three steps for whatever extra you want to include -(like Wagon transport, distributed locking, etc). - -First, you need to include needed module (with transitive deps) to your dependencies. - -Second, you need to customize `RepositorySystemSupplier` to make new components (`WagonTransporterFactory`, or -distributed lock factories) available. - -Third, you need to configure session (via user of config properties) to make Resolver use newly added components. \ No newline at end of file diff --git a/src/site/markdown/third-party-integrations.md b/src/site/markdown/third-party-integrations.md new file mode 100644 index 000000000..9a96771c9 --- /dev/null +++ b/src/site/markdown/third-party-integrations.md @@ -0,0 +1,72 @@ +# Third-party integrations + + +Maven Resolver provided option for third-party integration using `ServiceLocator` (SL) +from the beginning. Back when SL was implemented, the DI container in use with Resolver and +Maven was the Plexus DI container, that had its own limitations: no constructor injection +among others. Hence, the two was somewhat aligned with each other. Today, with Sisu DI, +this is not true anymore: we want to use constructor injection for components, but +SL is always getting into our way forcing us to always add default constructor to components. +Hence, decision was made, and SL was deprecated while ago, and is about to be +dropped in Resolver 2.0.0 release. + +Resolver does provide alternative solution for those third-party integrations, where the +(recommended) Sisu DI is not available or cannot be used for some reason. All the +resolver integrations starting with release 1.9.15 can start migrating off the SL +to current solution described below. + +## Maven Resolver Supplier + +A new simple module `maven-resolver-supplier` serves the purpose to "bootstrap" resolver instance +when there is no desire to use [Eclipse Sisu](https://eclipse.dev/sisu/) DI. It provides one simple class +`org.eclipse.aether.supplier.RepositorySystemSupplier` that implements `Supplier` +and supplies ready-to-use `RepositorySystem` instances. The `RepositorySystemSession` should be +created using the `org.apache.maven.repository.internal.MavenRepositorySystemUtils#newSession()` method +and local repository added to it in usual way (there is no change in this area). + +The supplier class is written in a way, to allow easy customization if needed: just extend the class and override +method as needed (all methods are protected). + +Consumer/users of this module **must provide SLF4J implementation** in classpath. Resolver uses `slf4j-api` for +logging purposes, but this module does NOT provide any implementation for it as a dependency. +It is the consumer/user obligation to provide one at runtime. + +Version of `maven-resolver-supplier` artifact in use **must be strictly aligned** with other Resolver artifacts +on classpath. + +## Resolver configuration + +By default, "full resolver experience" is provided: +* for connector, the connector-basic is provided +* for transport the two transport-file and transport-http implementations are provided. If Wagon is needed, add + transport-wagon as dependency (see Extending Resolver below). + +The supplier will provide fully usable instance. To configure resolver, use session user (or +configuration) properties, when constructing session. All the configuration options are available as +[listed here](https://maven.apache.org/resolver/configuration.html). + +## Extending Resolver + +Extending supplied resolver is simple, and basically requires same three steps for whatever extra you want to include +(like Wagon transport, distributed locking, etc). + +* First, you need to include needed module (with transitive deps) to your dependencies. +* Second, you need to customize `RepositorySystemSupplier` by extending it, and to make new components + available (by adding `WagonTransporterFactory` to transport factories, or distributed lock factories to lock factories). +* Third, you need to configure session (via user or configuration properties) to make Resolver use newly added components. + diff --git a/src/site/site.xml b/src/site/site.xml index 3dbe96ff5..fdb5af531 100644 --- a/src/site/site.xml +++ b/src/site/site.xml @@ -32,6 +32,7 @@ under the License. + From ee3e275edb031f9b3dc42998a75db97dea703dc8 Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Fri, 4 Aug 2023 14:24:41 +0200 Subject: [PATCH 07/23] [maven-release-plugin] prepare release maven-resolver-1.9.15 --- maven-resolver-api/pom.xml | 2 +- maven-resolver-connector-basic/pom.xml | 2 +- .../maven-resolver-demo-maven-plugin/pom.xml | 2 +- maven-resolver-demos/maven-resolver-demo-snippets/pom.xml | 2 +- maven-resolver-demos/pom.xml | 2 +- maven-resolver-impl/pom.xml | 2 +- maven-resolver-named-locks-hazelcast/pom.xml | 2 +- maven-resolver-named-locks-redisson/pom.xml | 2 +- maven-resolver-named-locks/pom.xml | 2 +- maven-resolver-spi/pom.xml | 2 +- maven-resolver-supplier/pom.xml | 2 +- maven-resolver-test-util/pom.xml | 2 +- maven-resolver-transport-classpath/pom.xml | 2 +- maven-resolver-transport-file/pom.xml | 2 +- maven-resolver-transport-http/pom.xml | 2 +- maven-resolver-transport-wagon/pom.xml | 2 +- maven-resolver-util/pom.xml | 2 +- pom.xml | 6 +++--- 18 files changed, 20 insertions(+), 20 deletions(-) diff --git a/maven-resolver-api/pom.xml b/maven-resolver-api/pom.xml index 691aeb33d..55e68106e 100644 --- a/maven-resolver-api/pom.xml +++ b/maven-resolver-api/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver - 1.9.15-SNAPSHOT + 1.9.15 maven-resolver-api diff --git a/maven-resolver-connector-basic/pom.xml b/maven-resolver-connector-basic/pom.xml index 2f9333ebb..53923f618 100644 --- a/maven-resolver-connector-basic/pom.xml +++ b/maven-resolver-connector-basic/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver - 1.9.15-SNAPSHOT + 1.9.15 maven-resolver-connector-basic diff --git a/maven-resolver-demos/maven-resolver-demo-maven-plugin/pom.xml b/maven-resolver-demos/maven-resolver-demo-maven-plugin/pom.xml index 8af0caebb..9f28b4d52 100644 --- a/maven-resolver-demos/maven-resolver-demo-maven-plugin/pom.xml +++ b/maven-resolver-demos/maven-resolver-demo-maven-plugin/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver-demos - 1.9.15-SNAPSHOT + 1.9.15 resolver-demo-maven-plugin diff --git a/maven-resolver-demos/maven-resolver-demo-snippets/pom.xml b/maven-resolver-demos/maven-resolver-demo-snippets/pom.xml index f4c34e50a..2f5d30df8 100644 --- a/maven-resolver-demos/maven-resolver-demo-snippets/pom.xml +++ b/maven-resolver-demos/maven-resolver-demo-snippets/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver-demos - 1.9.15-SNAPSHOT + 1.9.15 maven-resolver-demo-snippets diff --git a/maven-resolver-demos/pom.xml b/maven-resolver-demos/pom.xml index 49a7a267a..7039e8a8e 100644 --- a/maven-resolver-demos/pom.xml +++ b/maven-resolver-demos/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver - 1.9.15-SNAPSHOT + 1.9.15 maven-resolver-demos diff --git a/maven-resolver-impl/pom.xml b/maven-resolver-impl/pom.xml index a206060cb..82b787690 100644 --- a/maven-resolver-impl/pom.xml +++ b/maven-resolver-impl/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver - 1.9.15-SNAPSHOT + 1.9.15 maven-resolver-impl diff --git a/maven-resolver-named-locks-hazelcast/pom.xml b/maven-resolver-named-locks-hazelcast/pom.xml index bff963b1a..905f1c0e7 100644 --- a/maven-resolver-named-locks-hazelcast/pom.xml +++ b/maven-resolver-named-locks-hazelcast/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver - 1.9.15-SNAPSHOT + 1.9.15 maven-resolver-named-locks-hazelcast diff --git a/maven-resolver-named-locks-redisson/pom.xml b/maven-resolver-named-locks-redisson/pom.xml index 1d09b4ae0..50cbdb4ae 100644 --- a/maven-resolver-named-locks-redisson/pom.xml +++ b/maven-resolver-named-locks-redisson/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver - 1.9.15-SNAPSHOT + 1.9.15 maven-resolver-named-locks-redisson diff --git a/maven-resolver-named-locks/pom.xml b/maven-resolver-named-locks/pom.xml index 27a320478..49b0a5f54 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 + 1.9.15 maven-resolver-named-locks diff --git a/maven-resolver-spi/pom.xml b/maven-resolver-spi/pom.xml index 53bf13e11..c4eea5533 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 + 1.9.15 maven-resolver-spi diff --git a/maven-resolver-supplier/pom.xml b/maven-resolver-supplier/pom.xml index d652bb01f..1a75b4a89 100644 --- a/maven-resolver-supplier/pom.xml +++ b/maven-resolver-supplier/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver - 1.9.15-SNAPSHOT + 1.9.15 maven-resolver-supplier diff --git a/maven-resolver-test-util/pom.xml b/maven-resolver-test-util/pom.xml index 6f3709712..6be4916c9 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 + 1.9.15 maven-resolver-test-util diff --git a/maven-resolver-transport-classpath/pom.xml b/maven-resolver-transport-classpath/pom.xml index 03f1a5e68..988d65424 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 + 1.9.15 maven-resolver-transport-classpath diff --git a/maven-resolver-transport-file/pom.xml b/maven-resolver-transport-file/pom.xml index 7ede9ce6d..94acc968f 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 + 1.9.15 maven-resolver-transport-file diff --git a/maven-resolver-transport-http/pom.xml b/maven-resolver-transport-http/pom.xml index 875d5adb1..7a190c8b6 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 + 1.9.15 maven-resolver-transport-http diff --git a/maven-resolver-transport-wagon/pom.xml b/maven-resolver-transport-wagon/pom.xml index ad8cf54ca..06a3c4b23 100644 --- a/maven-resolver-transport-wagon/pom.xml +++ b/maven-resolver-transport-wagon/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver - 1.9.15-SNAPSHOT + 1.9.15 maven-resolver-transport-wagon diff --git a/maven-resolver-util/pom.xml b/maven-resolver-util/pom.xml index 65cdef26d..f5ea1163b 100644 --- a/maven-resolver-util/pom.xml +++ b/maven-resolver-util/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver - 1.9.15-SNAPSHOT + 1.9.15 maven-resolver-util diff --git a/pom.xml b/pom.xml index a9f659eb0..22d4e7a70 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ org.apache.maven.resolver maven-resolver - 1.9.15-SNAPSHOT + 1.9.15 pom Maven Artifact Resolver @@ -65,7 +65,7 @@ scm:git:https://gitbox.apache.org/repos/asf/maven-resolver.git scm:git:https://gitbox.apache.org/repos/asf/maven-resolver.git - maven-resolver-1.9.14 + maven-resolver-1.9.15 https://github.com/apache/maven-resolver/tree/${project.scm.tag} @@ -96,7 +96,7 @@ 3.9.4 [3.8.7,) [1.8.0-362,) - 2023-07-20T09:56:17Z + 2023-08-04T12:23:21Z From f139fb4bba800c94d4b7fbc79c9abea7700333ba Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Fri, 4 Aug 2023 14:24:58 +0200 Subject: [PATCH 08/23] [maven-release-plugin] prepare for next development iteration --- maven-resolver-api/pom.xml | 2 +- maven-resolver-connector-basic/pom.xml | 2 +- .../maven-resolver-demo-maven-plugin/pom.xml | 2 +- maven-resolver-demos/maven-resolver-demo-snippets/pom.xml | 2 +- maven-resolver-demos/pom.xml | 2 +- maven-resolver-impl/pom.xml | 2 +- maven-resolver-named-locks-hazelcast/pom.xml | 2 +- maven-resolver-named-locks-redisson/pom.xml | 2 +- maven-resolver-named-locks/pom.xml | 2 +- maven-resolver-spi/pom.xml | 2 +- maven-resolver-supplier/pom.xml | 2 +- maven-resolver-test-util/pom.xml | 2 +- maven-resolver-transport-classpath/pom.xml | 2 +- maven-resolver-transport-file/pom.xml | 2 +- maven-resolver-transport-http/pom.xml | 2 +- maven-resolver-transport-wagon/pom.xml | 2 +- maven-resolver-util/pom.xml | 2 +- pom.xml | 6 +++--- 18 files changed, 20 insertions(+), 20 deletions(-) diff --git a/maven-resolver-api/pom.xml b/maven-resolver-api/pom.xml index 55e68106e..319d2c47c 100644 --- a/maven-resolver-api/pom.xml +++ b/maven-resolver-api/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver - 1.9.15 + 1.9.16-SNAPSHOT maven-resolver-api diff --git a/maven-resolver-connector-basic/pom.xml b/maven-resolver-connector-basic/pom.xml index 53923f618..8686b7a6c 100644 --- a/maven-resolver-connector-basic/pom.xml +++ b/maven-resolver-connector-basic/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver - 1.9.15 + 1.9.16-SNAPSHOT maven-resolver-connector-basic diff --git a/maven-resolver-demos/maven-resolver-demo-maven-plugin/pom.xml b/maven-resolver-demos/maven-resolver-demo-maven-plugin/pom.xml index 9f28b4d52..91dd42f65 100644 --- a/maven-resolver-demos/maven-resolver-demo-maven-plugin/pom.xml +++ b/maven-resolver-demos/maven-resolver-demo-maven-plugin/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver-demos - 1.9.15 + 1.9.16-SNAPSHOT resolver-demo-maven-plugin diff --git a/maven-resolver-demos/maven-resolver-demo-snippets/pom.xml b/maven-resolver-demos/maven-resolver-demo-snippets/pom.xml index 2f5d30df8..20f4774cb 100644 --- a/maven-resolver-demos/maven-resolver-demo-snippets/pom.xml +++ b/maven-resolver-demos/maven-resolver-demo-snippets/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver-demos - 1.9.15 + 1.9.16-SNAPSHOT maven-resolver-demo-snippets diff --git a/maven-resolver-demos/pom.xml b/maven-resolver-demos/pom.xml index 7039e8a8e..0b80c2aae 100644 --- a/maven-resolver-demos/pom.xml +++ b/maven-resolver-demos/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver - 1.9.15 + 1.9.16-SNAPSHOT maven-resolver-demos diff --git a/maven-resolver-impl/pom.xml b/maven-resolver-impl/pom.xml index 82b787690..1625e3ca6 100644 --- a/maven-resolver-impl/pom.xml +++ b/maven-resolver-impl/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver - 1.9.15 + 1.9.16-SNAPSHOT maven-resolver-impl diff --git a/maven-resolver-named-locks-hazelcast/pom.xml b/maven-resolver-named-locks-hazelcast/pom.xml index 905f1c0e7..60d4725a8 100644 --- a/maven-resolver-named-locks-hazelcast/pom.xml +++ b/maven-resolver-named-locks-hazelcast/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver - 1.9.15 + 1.9.16-SNAPSHOT maven-resolver-named-locks-hazelcast diff --git a/maven-resolver-named-locks-redisson/pom.xml b/maven-resolver-named-locks-redisson/pom.xml index 50cbdb4ae..5a2e13a66 100644 --- a/maven-resolver-named-locks-redisson/pom.xml +++ b/maven-resolver-named-locks-redisson/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver - 1.9.15 + 1.9.16-SNAPSHOT maven-resolver-named-locks-redisson diff --git a/maven-resolver-named-locks/pom.xml b/maven-resolver-named-locks/pom.xml index 49b0a5f54..ac22191d7 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 + 1.9.16-SNAPSHOT maven-resolver-named-locks diff --git a/maven-resolver-spi/pom.xml b/maven-resolver-spi/pom.xml index c4eea5533..5acffd63f 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 + 1.9.16-SNAPSHOT maven-resolver-spi diff --git a/maven-resolver-supplier/pom.xml b/maven-resolver-supplier/pom.xml index 1a75b4a89..5472ce3fe 100644 --- a/maven-resolver-supplier/pom.xml +++ b/maven-resolver-supplier/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver - 1.9.15 + 1.9.16-SNAPSHOT maven-resolver-supplier diff --git a/maven-resolver-test-util/pom.xml b/maven-resolver-test-util/pom.xml index 6be4916c9..69639c7d1 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 + 1.9.16-SNAPSHOT maven-resolver-test-util diff --git a/maven-resolver-transport-classpath/pom.xml b/maven-resolver-transport-classpath/pom.xml index 988d65424..ec0e3da1f 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 + 1.9.16-SNAPSHOT maven-resolver-transport-classpath diff --git a/maven-resolver-transport-file/pom.xml b/maven-resolver-transport-file/pom.xml index 94acc968f..63b7d3a5a 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 + 1.9.16-SNAPSHOT maven-resolver-transport-file diff --git a/maven-resolver-transport-http/pom.xml b/maven-resolver-transport-http/pom.xml index 7a190c8b6..54dd04c9f 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 + 1.9.16-SNAPSHOT maven-resolver-transport-http diff --git a/maven-resolver-transport-wagon/pom.xml b/maven-resolver-transport-wagon/pom.xml index 06a3c4b23..eed8484e3 100644 --- a/maven-resolver-transport-wagon/pom.xml +++ b/maven-resolver-transport-wagon/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver - 1.9.15 + 1.9.16-SNAPSHOT maven-resolver-transport-wagon diff --git a/maven-resolver-util/pom.xml b/maven-resolver-util/pom.xml index f5ea1163b..b8a1d5976 100644 --- a/maven-resolver-util/pom.xml +++ b/maven-resolver-util/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver - 1.9.15 + 1.9.16-SNAPSHOT maven-resolver-util diff --git a/pom.xml b/pom.xml index 22d4e7a70..fb3f874d5 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ org.apache.maven.resolver maven-resolver - 1.9.15 + 1.9.16-SNAPSHOT pom Maven Artifact Resolver @@ -65,7 +65,7 @@ scm:git:https://gitbox.apache.org/repos/asf/maven-resolver.git scm:git:https://gitbox.apache.org/repos/asf/maven-resolver.git - maven-resolver-1.9.15 + maven-resolver-1.9.14 https://github.com/apache/maven-resolver/tree/${project.scm.tag} @@ -96,7 +96,7 @@ 3.9.4 [3.8.7,) [1.8.0-362,) - 2023-08-04T12:23:21Z + 2023-08-04T12:24:58Z From a8ccec6bd11fac2c899ebfd55dd6b69937858b66 Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Tue, 29 Aug 2023 12:49:41 +0100 Subject: [PATCH 09/23] [MNG-6847] Use diamond operator (#327) As discussed on - https://github.com/apache/maven-scm/pull/184 - https://issues.apache.org/jira/browse/MNG-6847 Review requested of @elharo Use this link to re-run the recipe: https://app.moderne.io/recipes/org.openrewrite.staticanalysis.UseDiamondOperator?organizationId=QXBhY2hlIE1hdmVu Co-authored-by: Moderne --- .../eclipse/aether/internal/impl/DefaultRepositorySystem.java | 3 +-- .../aether/internal/impl/StubFileTransformerManager.java | 2 +- .../aether/internal/test/util/IniArtifactDataReader.java | 2 +- .../java/org/eclipse/aether/transport/http/HttpServer.java | 2 +- .../util/filter/PatternExclusionsDependencyFilterTest.java | 4 ++-- .../util/filter/PatternInclusionsDependencyFilterTest.java | 4 ++-- 6 files changed, 8 insertions(+), 9 deletions(-) diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRepositorySystem.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRepositorySystem.java index 8477d5bb3..d2ba9e0a9 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRepositorySystem.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRepositorySystem.java @@ -418,8 +418,7 @@ public List newResolutionRepositories( validateSession(session); validateRepositories(repositories); - repositories = remoteRepositoryManager.aggregateRepositories( - session, new ArrayList(), repositories, true); + repositories = remoteRepositoryManager.aggregateRepositories(session, new ArrayList<>(), repositories, true); return repositories; } diff --git a/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/StubFileTransformerManager.java b/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/StubFileTransformerManager.java index 284858bbb..808f60537 100644 --- a/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/StubFileTransformerManager.java +++ b/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/StubFileTransformerManager.java @@ -37,7 +37,7 @@ public Collection getTransformersForArtifact(Artifact artifact) public void addFileTransformer(String extension, FileTransformer fileTransformer) { if (!fileTransformers.containsKey(extension)) { - fileTransformers.put(extension, new HashSet()); + fileTransformers.put(extension, new HashSet<>()); } fileTransformers.get(extension).add(fileTransformer); } 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-transport-http/src/test/java/org/eclipse/aether/transport/http/HttpServer.java b/maven-resolver-transport-http/src/test/java/org/eclipse/aether/transport/http/HttpServer.java index 0c46e31fa..29ff91a55 100644 --- a/maven-resolver-transport-http/src/test/java/org/eclipse/aether/transport/http/HttpServer.java +++ b/maven-resolver-transport-http/src/test/java/org/eclipse/aether/transport/http/HttpServer.java @@ -113,7 +113,7 @@ public enum ChecksumHeader { private final AtomicInteger connectionsToClose = new AtomicInteger(0); - private List logEntries = Collections.synchronizedList(new ArrayList()); + private List logEntries = Collections.synchronizedList(new ArrayList<>()); public String getHost() { return "localhost"; diff --git a/maven-resolver-util/src/test/java/org/eclipse/aether/util/filter/PatternExclusionsDependencyFilterTest.java b/maven-resolver-util/src/test/java/org/eclipse/aether/util/filter/PatternExclusionsDependencyFilterTest.java index 3a716b390..e6d1c00e3 100644 --- a/maven-resolver-util/src/test/java/org/eclipse/aether/util/filter/PatternExclusionsDependencyFilterTest.java +++ b/maven-resolver-util/src/test/java/org/eclipse/aether/util/filter/PatternExclusionsDependencyFilterTest.java @@ -177,11 +177,11 @@ public void acceptTestRange() { } private boolean dontAccept(DependencyNode node, String expression) { - return !new PatternExclusionsDependencyFilter(expression).accept(node, new LinkedList()); + return !new PatternExclusionsDependencyFilter(expression).accept(node, new LinkedList<>()); } private boolean dontAcceptVersionRange(DependencyNode node, String... expression) { return !new PatternExclusionsDependencyFilter(new GenericVersionScheme(), expression) - .accept(node, new LinkedList()); + .accept(node, new LinkedList<>()); } } diff --git a/maven-resolver-util/src/test/java/org/eclipse/aether/util/filter/PatternInclusionsDependencyFilterTest.java b/maven-resolver-util/src/test/java/org/eclipse/aether/util/filter/PatternInclusionsDependencyFilterTest.java index 3117a24ad..9b022d595 100644 --- a/maven-resolver-util/src/test/java/org/eclipse/aether/util/filter/PatternInclusionsDependencyFilterTest.java +++ b/maven-resolver-util/src/test/java/org/eclipse/aether/util/filter/PatternInclusionsDependencyFilterTest.java @@ -169,11 +169,11 @@ public void acceptTestRange() { } public boolean accept(DependencyNode node, String expression) { - return new PatternInclusionsDependencyFilter(expression).accept(node, new LinkedList()); + return new PatternInclusionsDependencyFilter(expression).accept(node, new LinkedList<>()); } public boolean acceptVersionRange(DependencyNode node, String... expression) { return new PatternInclusionsDependencyFilter(new GenericVersionScheme(), expression) - .accept(node, new LinkedList()); + .accept(node, new LinkedList<>()); } } From 3c073bccc73ebe4265631eb8e2ca9616c89afbd0 Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Mon, 4 Sep 2023 15:17:33 +0200 Subject: [PATCH 10/23] [MRESOLVER-396] Back off on too many requests (#326) Provide a way to "back off", and lower the request pace if remote claims "too many requests". Also, if server sends Retry-After header, obey that. --- https://issues.apache.org/jira/projects/MRESOLVER/issues/MRESOLVER-396 --- .../aether/ConfigurationProperties.java | 54 ++++++++ .../transport/http/HttpTransporter.java | 128 ++++++++++++++++++ src/site/markdown/configuration.md | 3 + 3 files changed, 185 insertions(+) diff --git a/maven-resolver-api/src/main/java/org/eclipse/aether/ConfigurationProperties.java b/maven-resolver-api/src/main/java/org/eclipse/aether/ConfigurationProperties.java index fc435d878..a5519514d 100644 --- a/maven-resolver-api/src/main/java/org/eclipse/aether/ConfigurationProperties.java +++ b/maven-resolver-api/src/main/java/org/eclipse/aether/ConfigurationProperties.java @@ -144,6 +144,60 @@ public final class ConfigurationProperties { */ public static final int DEFAULT_HTTP_RETRY_HANDLER_COUNT = 3; + /** + * The initial retry interval of request to a remote server should be waited in case of "too many requests" + * (HTTP codes 429 and 503). Accepts long as milliseconds. This value is used if remote server does not use + * {@code Retry-After} header, in which case Server value is obeyed. + * + * @see #DEFAULT_HTTP_RETRY_HANDLER_INTERVAL + * @since 1.9.16 + */ + public static final String HTTP_RETRY_HANDLER_INTERVAL = PREFIX_CONNECTOR + "http.retryHandler.interval"; + + /** + * The default initial retry interval to use if {@link #HTTP_RETRY_HANDLER_INTERVAL} isn't set. + * Default value 5000ms. + * + * @since 1.9.16 + */ + public static final long DEFAULT_HTTP_RETRY_HANDLER_INTERVAL = 5000L; + + /** + * The maximum retry interval of request to a remote server above which the request should be aborted instead. + * In theory, a malicious server could tell Maven "come back after 100 years" that would stall the build for + * some. Using this parameter Maven will fail the request instead, if interval is above this value. + * + * @see #DEFAULT_HTTP_RETRY_HANDLER_INTERVAL_MAX + * @since 1.9.16 + */ + public static final String HTTP_RETRY_HANDLER_INTERVAL_MAX = PREFIX_CONNECTOR + "http.retryHandler.intervalMax"; + + /** + * The default retry interval maximum to use if {@link #HTTP_RETRY_HANDLER_INTERVAL_MAX} isn't set. + * Default value 5 minutes. + * + * @since 1.9.16 + */ + public static final long DEFAULT_HTTP_RETRY_HANDLER_INTERVAL_MAX = 300_000L; + + /** + * The HTTP codes of remote server responses that should be handled as "too many requests" + * (examples: HTTP codes 429 and 503). Accepts comma separated list of HTTP response codes. + * + * @see #DEFAULT_HTTP_RETRY_HANDLER_SERVICE_UNAVAILABLE + * @since 1.9.16 + */ + public static final String HTTP_RETRY_HANDLER_SERVICE_UNAVAILABLE = + PREFIX_CONNECTOR + "http.retryHandler.serviceUnavailable"; + + /** + * The default HTTP codes of remote server responses that should be handled as "too many requests". + * Default value: "429,503". + * + * @since 1.9.16 + */ + public static final String DEFAULT_HTTP_RETRY_HANDLER_SERVICE_UNAVAILABLE = "429,503"; + /** * Should HTTP client use preemptive auth (w/ BASIC) or not? * diff --git a/maven-resolver-transport-http/src/main/java/org/eclipse/aether/transport/http/HttpTransporter.java b/maven-resolver-transport-http/src/main/java/org/eclipse/aether/transport/http/HttpTransporter.java index d1848cc95..870204747 100644 --- a/maven-resolver-transport-http/src/main/java/org/eclipse/aether/transport/http/HttpTransporter.java +++ b/maven-resolver-transport-http/src/main/java/org/eclipse/aether/transport/http/HttpTransporter.java @@ -34,8 +34,10 @@ import java.nio.file.attribute.FileTime; import java.util.Collections; import java.util.Date; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -44,12 +46,14 @@ import org.apache.http.HttpEntityEnclosingRequest; import org.apache.http.HttpHeaders; import org.apache.http.HttpHost; +import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; import org.apache.http.auth.AuthSchemeProvider; import org.apache.http.auth.AuthScope; import org.apache.http.client.CredentialsProvider; import org.apache.http.client.HttpRequestRetryHandler; import org.apache.http.client.HttpResponseException; +import org.apache.http.client.ServiceUnavailableRetryStrategy; import org.apache.http.client.config.AuthSchemes; import org.apache.http.client.config.RequestConfig; import org.apache.http.client.methods.CloseableHttpResponse; @@ -76,6 +80,7 @@ import org.apache.http.impl.client.DefaultHttpRequestRetryHandler; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.impl.client.StandardHttpRequestRetryHandler; +import org.apache.http.protocol.HttpContext; import org.apache.http.util.EntityUtils; import org.eclipse.aether.ConfigurationProperties; import org.eclipse.aether.RepositorySystemSession; @@ -147,6 +152,7 @@ final class HttpTransporter extends AbstractTransporter { private final boolean supportWebDav; + @SuppressWarnings("checkstyle:methodlength") HttpTransporter( Map checksumExtractors, RemoteRepository repository, @@ -230,6 +236,21 @@ final class HttpTransporter extends AbstractTransporter { ConfigurationProperties.DEFAULT_HTTP_RETRY_HANDLER_COUNT, ConfigurationProperties.HTTP_RETRY_HANDLER_COUNT + "." + repository.getId(), ConfigurationProperties.HTTP_RETRY_HANDLER_COUNT); + long retryInterval = ConfigUtils.getLong( + session, + ConfigurationProperties.DEFAULT_HTTP_RETRY_HANDLER_INTERVAL, + ConfigurationProperties.HTTP_RETRY_HANDLER_INTERVAL + "." + repository.getId(), + ConfigurationProperties.HTTP_RETRY_HANDLER_INTERVAL); + long retryIntervalMax = ConfigUtils.getLong( + session, + ConfigurationProperties.DEFAULT_HTTP_RETRY_HANDLER_INTERVAL_MAX, + ConfigurationProperties.HTTP_RETRY_HANDLER_INTERVAL_MAX + "." + repository.getId(), + ConfigurationProperties.HTTP_RETRY_HANDLER_INTERVAL_MAX); + String serviceUnavailableCodesString = ConfigUtils.getString( + session, + ConfigurationProperties.DEFAULT_HTTP_RETRY_HANDLER_SERVICE_UNAVAILABLE, + ConfigurationProperties.HTTP_RETRY_HANDLER_SERVICE_UNAVAILABLE + "." + repository.getId(), + ConfigurationProperties.HTTP_RETRY_HANDLER_SERVICE_UNAVAILABLE); String retryHandlerName = ConfigUtils.getString( session, HTTP_RETRY_HANDLER_NAME_STANDARD, @@ -269,11 +290,24 @@ final class HttpTransporter extends AbstractTransporter { throw new IllegalArgumentException( "Unsupported parameter " + HTTP_RETRY_HANDLER_NAME + " value: " + retryHandlerName); } + Set serviceUnavailableCodes = new HashSet<>(); + try { + for (String code : ConfigUtils.parseCommaSeparatedUniqueNames(serviceUnavailableCodesString)) { + serviceUnavailableCodes.add(Integer.parseInt(code)); + } + } catch (NumberFormatException e) { + throw new IllegalArgumentException( + "Illegal HTTP codes for " + ConfigurationProperties.HTTP_RETRY_HANDLER_SERVICE_UNAVAILABLE + + " (list of integers): " + serviceUnavailableCodesString); + } + ServiceUnavailableRetryStrategy serviceUnavailableRetryStrategy = new ResolverServiceUnavailableRetryStrategy( + retryCount, retryInterval, retryIntervalMax, serviceUnavailableCodes); HttpClientBuilder builder = HttpClientBuilder.create() .setUserAgent(userAgent) .setDefaultSocketConfig(socketConfig) .setDefaultRequestConfig(requestConfig) + .setServiceUnavailableRetryStrategy(serviceUnavailableRetryStrategy) .setRetryHandler(retryHandler) .setDefaultAuthSchemeRegistry(authSchemeRegistry) .setConnectionManager(state.getConnectionManager()) @@ -704,4 +738,98 @@ public void writeTo(OutputStream os) throws IOException { } } } + + private static class ResolverServiceUnavailableRetryStrategy implements ServiceUnavailableRetryStrategy { + private final int retryCount; + + private final long retryInterval; + + private final long retryIntervalMax; + + private final Set serviceUnavailableHttpCodes; + + /** + * Ugly, but forced by HttpClient API {@link ServiceUnavailableRetryStrategy}: the calls for + * {@link #retryRequest(HttpResponse, int, HttpContext)} and {@link #getRetryInterval()} are done by same + * thread and are actually done from spot that are very close to each other (almost subsequent calls). + */ + private static final ThreadLocal RETRY_INTERVAL_HOLDER = new ThreadLocal<>(); + + private ResolverServiceUnavailableRetryStrategy( + int retryCount, long retryInterval, long retryIntervalMax, Set serviceUnavailableHttpCodes) { + if (retryCount < 0) { + throw new IllegalArgumentException("retryCount must be >= 0"); + } + if (retryInterval < 0L) { + throw new IllegalArgumentException("retryInterval must be >= 0"); + } + if (retryIntervalMax < 0L) { + throw new IllegalArgumentException("retryIntervalMax must be >= 0"); + } + this.retryCount = retryCount; + this.retryInterval = retryInterval; + this.retryIntervalMax = retryIntervalMax; + this.serviceUnavailableHttpCodes = requireNonNull(serviceUnavailableHttpCodes); + } + + @Override + public boolean retryRequest(HttpResponse response, int executionCount, HttpContext context) { + final boolean retry = executionCount <= retryCount + && (serviceUnavailableHttpCodes.contains( + response.getStatusLine().getStatusCode())); + if (retry) { + Long retryInterval = retryInterval(response, executionCount, context); + if (retryInterval != null) { + RETRY_INTERVAL_HOLDER.set(retryInterval); + return true; + } + } + RETRY_INTERVAL_HOLDER.remove(); + return false; + } + + /** + * Calculates retry interval in milliseconds. If {@link HttpHeaders#RETRY_AFTER} header present, it obeys it. + * Otherwise, it returns {@link this#retryInterval} long value multiplied with {@code executionCount} (starts + * from 1 and goes 2, 3,...). + * + * @return Long representing the retry interval as millis, or {@code null} if the request should be failed. + */ + private Long retryInterval(HttpResponse httpResponse, int executionCount, HttpContext httpContext) { + Long result = null; + Header header = httpResponse.getFirstHeader(HttpHeaders.RETRY_AFTER); + if (header != null && header.getValue() != null) { + String headerValue = header.getValue(); + if (headerValue.contains(":")) { // is date when to retry + Date when = DateUtils.parseDate(headerValue); // presumably future + if (when != null) { + result = Math.max(when.getTime() - System.currentTimeMillis(), 0L); + } + } else { + try { + result = Long.parseLong(headerValue) * 1000L; // is in seconds + } catch (NumberFormatException e) { + // fall through + } + } + } + if (result == null) { + result = executionCount * this.retryInterval; + } + if (result > retryIntervalMax) { + return null; + } + return result; + } + + @Override + public long getRetryInterval() { + Long ri = RETRY_INTERVAL_HOLDER.get(); + if (ri == null) { + return 0L; + } + RETRY_INTERVAL_HOLDER.remove(); + return ri; + } + } } diff --git a/src/site/markdown/configuration.md b/src/site/markdown/configuration.md index 4f66f3f43..fbee0a98e 100644 --- a/src/site/markdown/configuration.md +++ b/src/site/markdown/configuration.md @@ -43,8 +43,11 @@ Option | Type | Description | Default Value | Supports Repo ID Suffix `aether.connector.http.preemptiveAuth` | boolean | Should HTTP client use preemptive-authentication for all HTTP verbs (works only w/ BASIC). By default is disabled, as it is considered less secure. | `false` | yes `aether.connector.http.preemptivePutAuth` | boolean | Should HTTP client use preemptive-authentication for HTTP PUTs only (works only w/ BASIC). By default is enabled (same as Wagon). | `true` | yes `aether.connector.http.retryHandler.count` | int | The maximum number of times a request to a remote HTTP server should be retried in case of an error. | `3` | yes +`aether.connector.http.retryHandler.interval` | long | The initial retry interval in milliseconds, if server responds with "too many requests". Is multiplied by 1, 2,.. on each try. If server emits `Retry-After` header, it is obeyed instead of this value. | `5000` | yes +`aether.connector.http.retryHandler.intervalMax` | long | The retry interval maximum in milliseconds, after request should be given up (5 minutes). | `300000` | yes `aether.connector.http.retryHandler.name` | String | The name of retryHandler, supported values are "standard", that obeys RFC-2616, regarding idempotent methods, and "default" that considers requests w/o payload as idempotent. | `standard` | yes `aether.connector.http.retryHandler.requestSentEnabled` | boolean | Set to `true` if it is acceptable to retry non-idempotent requests, that have been sent. | `false` | yes +`aether.connector.http.retryHandler.serviceUnavailable` | String | Comma separated list of HTTP codes that should be handled as "too many requests". | `"429,503"` | yes `aether.connector.http.reuseConnections` | boolean | Should HTTP client reuse connections (in other words, pool connections) or not? | `true` | yes `aether.connector.http.supportWebDav` | boolean | If enabled, transport makes best effort to deploy to WebDAV server. This mode is not recommended, better use real Maven Repository Manager instead. | `false` | yes `aether.connector.http.useSystemProperties` | boolean | If enabled, underlying Apache HttpClient will use system properties as well to configure itself (typically used to set up HTTP Proxy via Java system properties). See HttpClientBuilder for used properties. This mode is **not recommended**, better use documented ways of configuration instead. | `false` | yes From f4c27eb8eb7d886a826e471495efc2ae9bca523f Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Wed, 6 Sep 2023 14:47:05 +0200 Subject: [PATCH 11/23] [MRESOLVER-397] Deprecate Guice integration (#328) Lowering the provided instantiation support from 3 to 2, to lower resources for maintenance all these. SL is about to be dropped, Guice same. Users should either use Sisu or use the new Supplier. --- https://issues.apache.org/jira/browse/MRESOLVER-397 --- .../main/java/org/eclipse/aether/impl/guice/AetherModule.java | 3 +++ .../main/java/org/eclipse/aether/impl/guice/package-info.java | 2 ++ 2 files changed, 5 insertions(+) diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/impl/guice/AetherModule.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/impl/guice/AetherModule.java index 1fef875bd..aad52e535 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/impl/guice/AetherModule.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/impl/guice/AetherModule.java @@ -128,7 +128,10 @@ * * @noextend This class must not be extended by clients and will eventually be marked {@code final} without prior * notice. + * @deprecated This class is about to be dropped in 2.0.0 release. Use SISU or use maven-resolver-supplier to + * get Resolver instances. */ +@Deprecated public class AetherModule extends AbstractModule { /** diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/impl/guice/package-info.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/impl/guice/package-info.java index a9ab92a79..91b686718 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/impl/guice/package-info.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/impl/guice/package-info.java @@ -20,5 +20,7 @@ /** * The integration with the dependency injection framework * Google Guice. + * + * @deprecated This package is about to be dropped in 2.0.0. */ package org.eclipse.aether.impl.guice; From 4605205db7d1a3f47f8e477cec08a699b7f5ac16 Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Wed, 6 Sep 2023 15:07:51 +0200 Subject: [PATCH 12/23] [MRESOLVER-399] Update Redisson to 3.23.4 (#329) Both are bugfix updates: * Hazelcast 5.3.1 -> 5.3.2 * Redisson 3.23.2 -> 3.23.4 --- https://issues.apache.org/jira/browse/MRESOLVER-399 --- maven-resolver-named-locks-hazelcast/pom.xml | 2 +- maven-resolver-named-locks-redisson/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/maven-resolver-named-locks-hazelcast/pom.xml b/maven-resolver-named-locks-hazelcast/pom.xml index 60d4725a8..61a017cfc 100644 --- a/maven-resolver-named-locks-hazelcast/pom.xml +++ b/maven-resolver-named-locks-hazelcast/pom.xml @@ -50,7 +50,7 @@ com.hazelcast hazelcast - 5.3.1 + 5.3.2 javax.inject diff --git a/maven-resolver-named-locks-redisson/pom.xml b/maven-resolver-named-locks-redisson/pom.xml index 5a2e13a66..bd2a56e55 100644 --- a/maven-resolver-named-locks-redisson/pom.xml +++ b/maven-resolver-named-locks-redisson/pom.xml @@ -50,7 +50,7 @@ org.redisson redisson - 3.23.2 + 3.23.4 org.slf4j From 345f55dabd9519016b4c347f52152e55195d8e79 Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Fri, 8 Sep 2023 16:08:09 +0200 Subject: [PATCH 13/23] [MRESOLVER-405] Get rid of component name free string literals (#330) Use NAME constants instead. --- https://issues.apache.org/jira/browse/MRESOLVER-405 --- .../basic/BasicRepositoryConnectorFactory.java | 3 ++- .../impl/EnhancedLocalRepositoryManagerFactory.java | 3 ++- .../internal/impl/Maven2RepositoryLayoutFactory.java | 3 ++- .../impl/SimpleLocalRepositoryManagerFactory.java | 3 ++- .../aether/supplier/RepositorySystemSupplier.java | 10 ++++++---- .../classpath/ClasspathTransporterFactory.java | 3 ++- .../aether/transport/file/FileTransporterFactory.java | 3 ++- .../aether/transport/http/HttpTransporterFactory.java | 4 +++- .../transport/wagon/WagonTransporterFactory.java | 3 ++- 9 files changed, 23 insertions(+), 12 deletions(-) diff --git a/maven-resolver-connector-basic/src/main/java/org/eclipse/aether/connector/basic/BasicRepositoryConnectorFactory.java b/maven-resolver-connector-basic/src/main/java/org/eclipse/aether/connector/basic/BasicRepositoryConnectorFactory.java index 76dc3116d..15470d3e3 100644 --- a/maven-resolver-connector-basic/src/main/java/org/eclipse/aether/connector/basic/BasicRepositoryConnectorFactory.java +++ b/maven-resolver-connector-basic/src/main/java/org/eclipse/aether/connector/basic/BasicRepositoryConnectorFactory.java @@ -44,8 +44,9 @@ * {@link org.eclipse.aether.spi.connector.transport.TransporterFactory transporters} and * {@link org.eclipse.aether.spi.connector.layout.RepositoryLayoutFactory repository layouts} for the transfers. */ -@Named("basic") +@Named(BasicRepositoryConnectorFactory.NAME) public final class BasicRepositoryConnectorFactory implements RepositoryConnectorFactory, Service { + public static final String NAME = "basic"; private TransporterProvider transporterProvider; private RepositoryLayoutProvider layoutProvider; diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/EnhancedLocalRepositoryManagerFactory.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/EnhancedLocalRepositoryManagerFactory.java index ec1c5583c..a0e0a558d 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/EnhancedLocalRepositoryManagerFactory.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/EnhancedLocalRepositoryManagerFactory.java @@ -41,8 +41,9 @@ * emulating physically separated artifact caches per remote repository. */ @Singleton -@Named("enhanced") +@Named(EnhancedLocalRepositoryManagerFactory.NAME) public class EnhancedLocalRepositoryManagerFactory implements LocalRepositoryManagerFactory, Service { + public static final String NAME = "enhanced"; private static final String CONFIG_PROP_TRACKING_FILENAME = "aether.enhancedLocalRepository.trackingFilename"; private static final String DEFAULT_TRACKING_FILENAME = "_remote.repositories"; diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/Maven2RepositoryLayoutFactory.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/Maven2RepositoryLayoutFactory.java index e9a1ccd70..8e52d18e8 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/Maven2RepositoryLayoutFactory.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/Maven2RepositoryLayoutFactory.java @@ -49,8 +49,9 @@ * Provides a Maven-2 repository layout for repositories with content type {@code "default"}. */ @Singleton -@Named("maven2") +@Named(Maven2RepositoryLayoutFactory.NAME) public final class Maven2RepositoryLayoutFactory implements RepositoryLayoutFactory { + public static final String NAME = "maven2"; public static final String CONFIG_PROP_CHECKSUMS_ALGORITHMS = "aether.checksums.algorithms"; diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/SimpleLocalRepositoryManagerFactory.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/SimpleLocalRepositoryManagerFactory.java index 1fe6d19eb..68974b304 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/SimpleLocalRepositoryManagerFactory.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/SimpleLocalRepositoryManagerFactory.java @@ -36,8 +36,9 @@ * Creates local repository managers for repository type {@code "simple"}. */ @Singleton -@Named("simple") +@Named(SimpleLocalRepositoryManagerFactory.NAME) public class SimpleLocalRepositoryManagerFactory implements LocalRepositoryManagerFactory, Service { + public static final String NAME = "simple"; private float priority; private LocalPathComposer localPathComposer; 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 index f20023352..13616c523 100644 --- 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 @@ -220,7 +220,9 @@ protected ChecksumAlgorithmFactorySelector getChecksumAlgorithmFactorySelector( protected Map getRepositoryLayoutFactories( ChecksumAlgorithmFactorySelector checksumAlgorithmFactorySelector) { HashMap result = new HashMap<>(); - result.put("maven2", new Maven2RepositoryLayoutFactory(checksumAlgorithmFactorySelector)); + result.put( + Maven2RepositoryLayoutFactory.NAME, + new Maven2RepositoryLayoutFactory(checksumAlgorithmFactorySelector)); return result; } @@ -303,8 +305,8 @@ protected Map getChecksumExtractors() { protected Map getTransporterFactories(Map extractors) { HashMap result = new HashMap<>(); - result.put("file", new FileTransporterFactory()); - result.put("http", new HttpTransporterFactory(extractors)); + result.put(FileTransporterFactory.NAME, new FileTransporterFactory()); + result.put(HttpTransporterFactory.NAME, new HttpTransporterFactory(extractors)); return result; } @@ -329,7 +331,7 @@ protected BasicRepositoryConnectorFactory getBasicRepositoryConnectorFactory( protected Map getRepositoryConnectorFactories( BasicRepositoryConnectorFactory basicRepositoryConnectorFactory) { HashMap result = new HashMap<>(); - result.put("basic", basicRepositoryConnectorFactory); + result.put(BasicRepositoryConnectorFactory.NAME, basicRepositoryConnectorFactory); return result; } 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/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/src/main/java/org/eclipse/aether/transport/http/HttpTransporterFactory.java b/maven-resolver-transport-http/src/main/java/org/eclipse/aether/transport/http/HttpTransporterFactory.java index f11670485..8cd098b10 100644 --- a/maven-resolver-transport-http/src/main/java/org/eclipse/aether/transport/http/HttpTransporterFactory.java +++ b/maven-resolver-transport-http/src/main/java/org/eclipse/aether/transport/http/HttpTransporterFactory.java @@ -37,8 +37,10 @@ * A transporter factory for repositories using the {@code http:} or {@code https:} protocol. The provided transporters * support uploads to WebDAV servers and resumable downloads. */ -@Named("http") +@Named(HttpTransporterFactory.NAME) public final class HttpTransporterFactory implements TransporterFactory { + public static final String NAME = "http"; + private static Map getManuallyCreatedExtractors() { HashMap map = new HashMap<>(); map.put(Nexus2ChecksumExtractor.NAME, new Nexus2ChecksumExtractor()); diff --git a/maven-resolver-transport-wagon/src/main/java/org/eclipse/aether/transport/wagon/WagonTransporterFactory.java b/maven-resolver-transport-wagon/src/main/java/org/eclipse/aether/transport/wagon/WagonTransporterFactory.java index bdac5e9d8..dcd354b89 100644 --- a/maven-resolver-transport-wagon/src/main/java/org/eclipse/aether/transport/wagon/WagonTransporterFactory.java +++ b/maven-resolver-transport-wagon/src/main/java/org/eclipse/aether/transport/wagon/WagonTransporterFactory.java @@ -36,8 +36,9 @@ * that this factory merely serves as an adapter to the Wagon API and by itself does not provide any transport services * unless one or more wagon implementations are registered with the {@link WagonProvider}. */ -@Named("wagon") +@Named(WagonTransporterFactory.NAME) public final class WagonTransporterFactory implements TransporterFactory, Service { + public static final String NAME = "wagon"; private WagonProvider wagonProvider; From 413b12c60dd9d75521e853a2d32dda6e611c0055 Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Fri, 8 Sep 2023 16:12:47 +0200 Subject: [PATCH 14/23] Add TODO for last free form string literals --- .../org/eclipse/aether/supplier/RepositorySystemSupplier.java | 1 + 1 file changed, 1 insertion(+) 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 index 13616c523..9e2f299a9 100644 --- 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 @@ -453,6 +453,7 @@ protected MetadataResolver getMetadataResolver( protected Map getMetadataGeneratorFactories() { // from maven-resolver-provider HashMap result = new HashMap<>(); + // TODO: Fix this once MNG-7874 done and released result.put("plugins", new PluginsMetadataGeneratorFactory()); result.put("versions", new VersionsMetadataGeneratorFactory()); result.put("snapshot", new SnapshotMetadataGeneratorFactory()); From feb8a052ed000d5207a34011137741659c37f42f Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Thu, 21 Sep 2023 22:43:13 +0200 Subject: [PATCH 15/23] [MRESOLVER-406] Update Jetty to 9.4.52.v20230823 (#332) --- https://issues.apache.org/jira/browse/MRESOLVER-406 --- maven-resolver-transport-http/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maven-resolver-transport-http/pom.xml b/maven-resolver-transport-http/pom.xml index 54dd04c9f..2332ed205 100644 --- a/maven-resolver-transport-http/pom.xml +++ b/maven-resolver-transport-http/pom.xml @@ -34,7 +34,7 @@ org.apache.maven.resolver.transport.http ${Automatic-Module-Name} - 9.4.51.v20230217 + 9.4.52.v20230823 From 0cfc557c55ccda67d0c3abc19fd80fd21581aa06 Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Fri, 22 Sep 2023 20:13:14 +0200 Subject: [PATCH 16/23] [maven-release-plugin] prepare release maven-resolver-1.9.16 --- maven-resolver-api/pom.xml | 2 +- maven-resolver-connector-basic/pom.xml | 2 +- .../maven-resolver-demo-maven-plugin/pom.xml | 2 +- maven-resolver-demos/maven-resolver-demo-snippets/pom.xml | 2 +- maven-resolver-demos/pom.xml | 2 +- maven-resolver-impl/pom.xml | 2 +- maven-resolver-named-locks-hazelcast/pom.xml | 2 +- maven-resolver-named-locks-redisson/pom.xml | 2 +- maven-resolver-named-locks/pom.xml | 2 +- maven-resolver-spi/pom.xml | 2 +- maven-resolver-supplier/pom.xml | 2 +- maven-resolver-test-util/pom.xml | 2 +- maven-resolver-transport-classpath/pom.xml | 2 +- maven-resolver-transport-file/pom.xml | 2 +- maven-resolver-transport-http/pom.xml | 2 +- maven-resolver-transport-wagon/pom.xml | 2 +- maven-resolver-util/pom.xml | 2 +- pom.xml | 6 +++--- 18 files changed, 20 insertions(+), 20 deletions(-) diff --git a/maven-resolver-api/pom.xml b/maven-resolver-api/pom.xml index 319d2c47c..de5a1a7ef 100644 --- a/maven-resolver-api/pom.xml +++ b/maven-resolver-api/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver - 1.9.16-SNAPSHOT + 1.9.16 maven-resolver-api diff --git a/maven-resolver-connector-basic/pom.xml b/maven-resolver-connector-basic/pom.xml index 8686b7a6c..734fe7e45 100644 --- a/maven-resolver-connector-basic/pom.xml +++ b/maven-resolver-connector-basic/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver - 1.9.16-SNAPSHOT + 1.9.16 maven-resolver-connector-basic diff --git a/maven-resolver-demos/maven-resolver-demo-maven-plugin/pom.xml b/maven-resolver-demos/maven-resolver-demo-maven-plugin/pom.xml index 91dd42f65..3a4456994 100644 --- a/maven-resolver-demos/maven-resolver-demo-maven-plugin/pom.xml +++ b/maven-resolver-demos/maven-resolver-demo-maven-plugin/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver-demos - 1.9.16-SNAPSHOT + 1.9.16 resolver-demo-maven-plugin diff --git a/maven-resolver-demos/maven-resolver-demo-snippets/pom.xml b/maven-resolver-demos/maven-resolver-demo-snippets/pom.xml index 20f4774cb..34a3831f0 100644 --- a/maven-resolver-demos/maven-resolver-demo-snippets/pom.xml +++ b/maven-resolver-demos/maven-resolver-demo-snippets/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver-demos - 1.9.16-SNAPSHOT + 1.9.16 maven-resolver-demo-snippets diff --git a/maven-resolver-demos/pom.xml b/maven-resolver-demos/pom.xml index 0b80c2aae..75d2d068e 100644 --- a/maven-resolver-demos/pom.xml +++ b/maven-resolver-demos/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver - 1.9.16-SNAPSHOT + 1.9.16 maven-resolver-demos diff --git a/maven-resolver-impl/pom.xml b/maven-resolver-impl/pom.xml index 1625e3ca6..06628cef3 100644 --- a/maven-resolver-impl/pom.xml +++ b/maven-resolver-impl/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver - 1.9.16-SNAPSHOT + 1.9.16 maven-resolver-impl diff --git a/maven-resolver-named-locks-hazelcast/pom.xml b/maven-resolver-named-locks-hazelcast/pom.xml index 61a017cfc..82c561d78 100644 --- a/maven-resolver-named-locks-hazelcast/pom.xml +++ b/maven-resolver-named-locks-hazelcast/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver - 1.9.16-SNAPSHOT + 1.9.16 maven-resolver-named-locks-hazelcast diff --git a/maven-resolver-named-locks-redisson/pom.xml b/maven-resolver-named-locks-redisson/pom.xml index bd2a56e55..6796430ac 100644 --- a/maven-resolver-named-locks-redisson/pom.xml +++ b/maven-resolver-named-locks-redisson/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver - 1.9.16-SNAPSHOT + 1.9.16 maven-resolver-named-locks-redisson diff --git a/maven-resolver-named-locks/pom.xml b/maven-resolver-named-locks/pom.xml index ac22191d7..69bc422e0 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.16-SNAPSHOT + 1.9.16 maven-resolver-named-locks diff --git a/maven-resolver-spi/pom.xml b/maven-resolver-spi/pom.xml index 5acffd63f..821de22fa 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.16-SNAPSHOT + 1.9.16 maven-resolver-spi diff --git a/maven-resolver-supplier/pom.xml b/maven-resolver-supplier/pom.xml index 5472ce3fe..c47cf2e47 100644 --- a/maven-resolver-supplier/pom.xml +++ b/maven-resolver-supplier/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver - 1.9.16-SNAPSHOT + 1.9.16 maven-resolver-supplier diff --git a/maven-resolver-test-util/pom.xml b/maven-resolver-test-util/pom.xml index 69639c7d1..a6fff52e2 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.16-SNAPSHOT + 1.9.16 maven-resolver-test-util diff --git a/maven-resolver-transport-classpath/pom.xml b/maven-resolver-transport-classpath/pom.xml index ec0e3da1f..f1cbcc3c7 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.16-SNAPSHOT + 1.9.16 maven-resolver-transport-classpath diff --git a/maven-resolver-transport-file/pom.xml b/maven-resolver-transport-file/pom.xml index 63b7d3a5a..e666e4d86 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.16-SNAPSHOT + 1.9.16 maven-resolver-transport-file diff --git a/maven-resolver-transport-http/pom.xml b/maven-resolver-transport-http/pom.xml index 2332ed205..19744c277 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.16-SNAPSHOT + 1.9.16 maven-resolver-transport-http diff --git a/maven-resolver-transport-wagon/pom.xml b/maven-resolver-transport-wagon/pom.xml index eed8484e3..a3cd4135a 100644 --- a/maven-resolver-transport-wagon/pom.xml +++ b/maven-resolver-transport-wagon/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver - 1.9.16-SNAPSHOT + 1.9.16 maven-resolver-transport-wagon diff --git a/maven-resolver-util/pom.xml b/maven-resolver-util/pom.xml index b8a1d5976..ea02100fa 100644 --- a/maven-resolver-util/pom.xml +++ b/maven-resolver-util/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver - 1.9.16-SNAPSHOT + 1.9.16 maven-resolver-util diff --git a/pom.xml b/pom.xml index fb3f874d5..8e3c76b05 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ org.apache.maven.resolver maven-resolver - 1.9.16-SNAPSHOT + 1.9.16 pom Maven Artifact Resolver @@ -65,7 +65,7 @@ scm:git:https://gitbox.apache.org/repos/asf/maven-resolver.git scm:git:https://gitbox.apache.org/repos/asf/maven-resolver.git - maven-resolver-1.9.14 + maven-resolver-1.9.16 https://github.com/apache/maven-resolver/tree/${project.scm.tag} @@ -96,7 +96,7 @@ 3.9.4 [3.8.7,) [1.8.0-362,) - 2023-08-04T12:24:58Z + 2023-09-22T18:12:06Z From 33d385e93633fe8dfb170f4ea29c14ab7053ba7e Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Fri, 22 Sep 2023 20:13:46 +0200 Subject: [PATCH 17/23] [maven-release-plugin] prepare for next development iteration --- maven-resolver-api/pom.xml | 2 +- maven-resolver-connector-basic/pom.xml | 2 +- .../maven-resolver-demo-maven-plugin/pom.xml | 2 +- maven-resolver-demos/maven-resolver-demo-snippets/pom.xml | 2 +- maven-resolver-demos/pom.xml | 2 +- maven-resolver-impl/pom.xml | 2 +- maven-resolver-named-locks-hazelcast/pom.xml | 2 +- maven-resolver-named-locks-redisson/pom.xml | 2 +- maven-resolver-named-locks/pom.xml | 2 +- maven-resolver-spi/pom.xml | 2 +- maven-resolver-supplier/pom.xml | 2 +- maven-resolver-test-util/pom.xml | 2 +- maven-resolver-transport-classpath/pom.xml | 2 +- maven-resolver-transport-file/pom.xml | 2 +- maven-resolver-transport-http/pom.xml | 2 +- maven-resolver-transport-wagon/pom.xml | 2 +- maven-resolver-util/pom.xml | 2 +- pom.xml | 6 +++--- 18 files changed, 20 insertions(+), 20 deletions(-) diff --git a/maven-resolver-api/pom.xml b/maven-resolver-api/pom.xml index de5a1a7ef..1d9773a80 100644 --- a/maven-resolver-api/pom.xml +++ b/maven-resolver-api/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver - 1.9.16 + 1.9.17-SNAPSHOT maven-resolver-api diff --git a/maven-resolver-connector-basic/pom.xml b/maven-resolver-connector-basic/pom.xml index 734fe7e45..e9061dd67 100644 --- a/maven-resolver-connector-basic/pom.xml +++ b/maven-resolver-connector-basic/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver - 1.9.16 + 1.9.17-SNAPSHOT maven-resolver-connector-basic diff --git a/maven-resolver-demos/maven-resolver-demo-maven-plugin/pom.xml b/maven-resolver-demos/maven-resolver-demo-maven-plugin/pom.xml index 3a4456994..15efba65a 100644 --- a/maven-resolver-demos/maven-resolver-demo-maven-plugin/pom.xml +++ b/maven-resolver-demos/maven-resolver-demo-maven-plugin/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver-demos - 1.9.16 + 1.9.17-SNAPSHOT resolver-demo-maven-plugin diff --git a/maven-resolver-demos/maven-resolver-demo-snippets/pom.xml b/maven-resolver-demos/maven-resolver-demo-snippets/pom.xml index 34a3831f0..d36ccc2d1 100644 --- a/maven-resolver-demos/maven-resolver-demo-snippets/pom.xml +++ b/maven-resolver-demos/maven-resolver-demo-snippets/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver-demos - 1.9.16 + 1.9.17-SNAPSHOT maven-resolver-demo-snippets diff --git a/maven-resolver-demos/pom.xml b/maven-resolver-demos/pom.xml index 75d2d068e..b1de669e9 100644 --- a/maven-resolver-demos/pom.xml +++ b/maven-resolver-demos/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver - 1.9.16 + 1.9.17-SNAPSHOT maven-resolver-demos diff --git a/maven-resolver-impl/pom.xml b/maven-resolver-impl/pom.xml index 06628cef3..98bf1c8a1 100644 --- a/maven-resolver-impl/pom.xml +++ b/maven-resolver-impl/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver - 1.9.16 + 1.9.17-SNAPSHOT maven-resolver-impl diff --git a/maven-resolver-named-locks-hazelcast/pom.xml b/maven-resolver-named-locks-hazelcast/pom.xml index 82c561d78..3c9d32f42 100644 --- a/maven-resolver-named-locks-hazelcast/pom.xml +++ b/maven-resolver-named-locks-hazelcast/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver - 1.9.16 + 1.9.17-SNAPSHOT maven-resolver-named-locks-hazelcast diff --git a/maven-resolver-named-locks-redisson/pom.xml b/maven-resolver-named-locks-redisson/pom.xml index 6796430ac..cf8840fd6 100644 --- a/maven-resolver-named-locks-redisson/pom.xml +++ b/maven-resolver-named-locks-redisson/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver - 1.9.16 + 1.9.17-SNAPSHOT maven-resolver-named-locks-redisson diff --git a/maven-resolver-named-locks/pom.xml b/maven-resolver-named-locks/pom.xml index 69bc422e0..177d897d7 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.16 + 1.9.17-SNAPSHOT maven-resolver-named-locks diff --git a/maven-resolver-spi/pom.xml b/maven-resolver-spi/pom.xml index 821de22fa..af2c1fcf1 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.16 + 1.9.17-SNAPSHOT maven-resolver-spi diff --git a/maven-resolver-supplier/pom.xml b/maven-resolver-supplier/pom.xml index c47cf2e47..e6e7c8c0a 100644 --- a/maven-resolver-supplier/pom.xml +++ b/maven-resolver-supplier/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver - 1.9.16 + 1.9.17-SNAPSHOT maven-resolver-supplier diff --git a/maven-resolver-test-util/pom.xml b/maven-resolver-test-util/pom.xml index a6fff52e2..5a709dad5 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.16 + 1.9.17-SNAPSHOT maven-resolver-test-util diff --git a/maven-resolver-transport-classpath/pom.xml b/maven-resolver-transport-classpath/pom.xml index f1cbcc3c7..694e85b6d 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.16 + 1.9.17-SNAPSHOT maven-resolver-transport-classpath diff --git a/maven-resolver-transport-file/pom.xml b/maven-resolver-transport-file/pom.xml index e666e4d86..024591eff 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.16 + 1.9.17-SNAPSHOT maven-resolver-transport-file diff --git a/maven-resolver-transport-http/pom.xml b/maven-resolver-transport-http/pom.xml index 19744c277..e087f0e7b 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.16 + 1.9.17-SNAPSHOT maven-resolver-transport-http diff --git a/maven-resolver-transport-wagon/pom.xml b/maven-resolver-transport-wagon/pom.xml index a3cd4135a..5985df226 100644 --- a/maven-resolver-transport-wagon/pom.xml +++ b/maven-resolver-transport-wagon/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver - 1.9.16 + 1.9.17-SNAPSHOT maven-resolver-transport-wagon diff --git a/maven-resolver-util/pom.xml b/maven-resolver-util/pom.xml index ea02100fa..cfaec8d0d 100644 --- a/maven-resolver-util/pom.xml +++ b/maven-resolver-util/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver - 1.9.16 + 1.9.17-SNAPSHOT maven-resolver-util diff --git a/pom.xml b/pom.xml index 8e3c76b05..2adbb19d0 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ org.apache.maven.resolver maven-resolver - 1.9.16 + 1.9.17-SNAPSHOT pom Maven Artifact Resolver @@ -65,7 +65,7 @@ scm:git:https://gitbox.apache.org/repos/asf/maven-resolver.git scm:git:https://gitbox.apache.org/repos/asf/maven-resolver.git - maven-resolver-1.9.16 + maven-resolver-1.9.14 https://github.com/apache/maven-resolver/tree/${project.scm.tag} @@ -96,7 +96,7 @@ 3.9.4 [3.8.7,) [1.8.0-362,) - 2023-09-22T18:12:06Z + 2023-09-22T18:13:46Z From 20d5424408fbdf4b49953b3df53cbc52e526ad0a Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Tue, 26 Sep 2023 14:10:28 +0200 Subject: [PATCH 18/23] [MNG-7416] Simplify Boolean expressions and returns (#333) Use this link to re-run the recipe: https://app.moderne.io/recipes/builder/SEvWu02zw?organizationId=QXBhY2hlIE1hdmVu Co-authored-by: Moderne --- .../internal/impl/DefaultMetadataResolver.java | 7 ++----- .../aether/util/artifact/ArtifactIdUtils.java | 15 +++------------ .../util/filter/ExclusionsDependencyFilter.java | 6 +----- .../selector/ExclusionDependencySelector.java | 5 +---- 4 files changed, 7 insertions(+), 26 deletions(-) diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultMetadataResolver.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultMetadataResolver.java index e28dd75bf..b0620cd7b 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultMetadataResolver.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultMetadataResolver.java @@ -435,11 +435,8 @@ private boolean isEnabled(RemoteRepository repository, Metadata.Nature nature) { && repository.getPolicy(false).isEnabled()) { return true; } - if (!Metadata.Nature.RELEASE.equals(nature) - && repository.getPolicy(true).isEnabled()) { - return true; - } - return false; + return !Metadata.Nature.RELEASE.equals(nature) + && repository.getPolicy(true).isEnabled(); } private RepositoryPolicy getPolicy( diff --git a/maven-resolver-util/src/main/java/org/eclipse/aether/util/artifact/ArtifactIdUtils.java b/maven-resolver-util/src/main/java/org/eclipse/aether/util/artifact/ArtifactIdUtils.java index 49901a73d..0d2a40180 100644 --- a/maven-resolver-util/src/main/java/org/eclipse/aether/util/artifact/ArtifactIdUtils.java +++ b/maven-resolver-util/src/main/java/org/eclipse/aether/util/artifact/ArtifactIdUtils.java @@ -165,10 +165,7 @@ public static boolean equalsId(Artifact artifact1, Artifact artifact2) { if (!Objects.equals(artifact1.getClassifier(), artifact2.getClassifier())) { return false; } - if (!Objects.equals(artifact1.getVersion(), artifact2.getVersion())) { - return false; - } - return true; + return Objects.equals(artifact1.getVersion(), artifact2.getVersion()); } /** @@ -196,10 +193,7 @@ public static boolean equalsBaseId(Artifact artifact1, Artifact artifact2) { if (!Objects.equals(artifact1.getClassifier(), artifact2.getClassifier())) { return false; } - if (!Objects.equals(artifact1.getBaseVersion(), artifact2.getBaseVersion())) { - return false; - } - return true; + return Objects.equals(artifact1.getBaseVersion(), artifact2.getBaseVersion()); } /** @@ -225,9 +219,6 @@ public static boolean equalsVersionlessId(Artifact artifact1, Artifact artifact2 if (!Objects.equals(artifact1.getExtension(), artifact2.getExtension())) { return false; } - if (!Objects.equals(artifact1.getClassifier(), artifact2.getClassifier())) { - return false; - } - return true; + return Objects.equals(artifact1.getClassifier(), artifact2.getClassifier()); } } diff --git a/maven-resolver-util/src/main/java/org/eclipse/aether/util/filter/ExclusionsDependencyFilter.java b/maven-resolver-util/src/main/java/org/eclipse/aether/util/filter/ExclusionsDependencyFilter.java index 12d745af3..8c6b18587 100644 --- a/maven-resolver-util/src/main/java/org/eclipse/aether/util/filter/ExclusionsDependencyFilter.java +++ b/maven-resolver-util/src/main/java/org/eclipse/aether/util/filter/ExclusionsDependencyFilter.java @@ -65,11 +65,7 @@ public boolean accept(DependencyNode node, List parents) { id = dependency.getArtifact().getGroupId() + ':' + id; - if (excludes.contains(id)) { - return false; - } - - return true; + return !(excludes.contains(id)); } @Override diff --git a/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/selector/ExclusionDependencySelector.java b/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/selector/ExclusionDependencySelector.java index a9d5a7efb..a44e8c816 100644 --- a/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/selector/ExclusionDependencySelector.java +++ b/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/selector/ExclusionDependencySelector.java @@ -90,10 +90,7 @@ private boolean matches(Exclusion exclusion, Artifact artifact) { if (!matches(exclusion.getExtension(), artifact.getExtension())) { return false; } - if (!matches(exclusion.getClassifier(), artifact.getClassifier())) { - return false; - } - return true; + return matches(exclusion.getClassifier(), artifact.getClassifier()); } private boolean matches(String pattern, String value) { From efa07719594d786bd83e2802f1e217a95860ba80 Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Thu, 12 Oct 2023 22:32:59 +0200 Subject: [PATCH 19/23] [MRESOLVER-407] Update to Maven 3.9.5 (#336) And get rid of deprecations (no-arg ctors) and string literals. --- https://issues.apache.org/jira/browse/MRESOLVER-407 --- .../supplier/RepositorySystemSupplier.java | 36 +++++++------------ pom.xml | 2 +- src/site/markdown/third-party-integrations.md | 15 +++++--- 3 files changed, 25 insertions(+), 28 deletions(-) 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 index 9e2f299a9..795265679 100644 --- 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 @@ -453,10 +453,9 @@ protected MetadataResolver getMetadataResolver( protected Map getMetadataGeneratorFactories() { // from maven-resolver-provider HashMap result = new HashMap<>(); - // TODO: Fix this once MNG-7874 done and released - result.put("plugins", new PluginsMetadataGeneratorFactory()); - result.put("versions", new VersionsMetadataGeneratorFactory()); - result.put("snapshot", new SnapshotMetadataGeneratorFactory()); + result.put(PluginsMetadataGeneratorFactory.NAME, new PluginsMetadataGeneratorFactory()); + result.put(VersionsMetadataGeneratorFactory.NAME, new VersionsMetadataGeneratorFactory()); + result.put(SnapshotMetadataGeneratorFactory.NAME, new SnapshotMetadataGeneratorFactory()); return result; } @@ -469,15 +468,14 @@ protected ArtifactDescriptorReader getArtifactDescriptorReader( RepositoryEventDispatcher repositoryEventDispatcher, ModelCacheFactory modelCacheFactory) { // from maven-resolver-provider - DefaultArtifactDescriptorReader result = new DefaultArtifactDescriptorReader(); - result.setRemoteRepositoryManager(remoteRepositoryManager); - result.setVersionResolver(versionResolver); - result.setVersionRangeResolver(versionRangeResolver); - result.setArtifactResolver(artifactResolver); - result.setModelBuilder(modelBuilder); - result.setRepositoryEventDispatcher(repositoryEventDispatcher); - result.setModelCacheFactory(modelCacheFactory); - return result; + return new DefaultArtifactDescriptorReader( + remoteRepositoryManager, + versionResolver, + versionRangeResolver, + artifactResolver, + modelBuilder, + repositoryEventDispatcher, + modelCacheFactory); } protected VersionResolver getVersionResolver( @@ -485,11 +483,7 @@ protected VersionResolver getVersionResolver( SyncContextFactory syncContextFactory, RepositoryEventDispatcher repositoryEventDispatcher) { // from maven-resolver-provider - DefaultVersionResolver result = new DefaultVersionResolver(); - result.setMetadataResolver(metadataResolver); - result.setSyncContextFactory(syncContextFactory); - result.setRepositoryEventDispatcher(repositoryEventDispatcher); - return result; + return new DefaultVersionResolver(metadataResolver, syncContextFactory, repositoryEventDispatcher); } protected VersionRangeResolver getVersionRangeResolver( @@ -497,11 +491,7 @@ protected VersionRangeResolver getVersionRangeResolver( SyncContextFactory syncContextFactory, RepositoryEventDispatcher repositoryEventDispatcher) { // from maven-resolver-provider - DefaultVersionRangeResolver result = new DefaultVersionRangeResolver(); - result.setMetadataResolver(metadataResolver); - result.setSyncContextFactory(syncContextFactory); - result.setRepositoryEventDispatcher(repositoryEventDispatcher); - return result; + return new DefaultVersionRangeResolver(metadataResolver, syncContextFactory, repositoryEventDispatcher); } protected ModelBuilder getModelBuilder() { diff --git a/pom.xml b/pom.xml index 2adbb19d0..2538a4331 100644 --- a/pom.xml +++ b/pom.xml @@ -93,7 +93,7 @@ 5.1.0 1.7.36 - 3.9.4 + 3.9.5 [3.8.7,) [1.8.0-362,) 2023-09-22T18:13:46Z diff --git a/src/site/markdown/third-party-integrations.md b/src/site/markdown/third-party-integrations.md index 9a96771c9..d0e1d218b 100644 --- a/src/site/markdown/third-party-integrations.md +++ b/src/site/markdown/third-party-integrations.md @@ -35,8 +35,12 @@ to current solution described below. A new simple module `maven-resolver-supplier` serves the purpose to "bootstrap" resolver instance when there is no desire to use [Eclipse Sisu](https://eclipse.dev/sisu/) DI. It provides one simple class `org.eclipse.aether.supplier.RepositorySystemSupplier` that implements `Supplier` -and supplies ready-to-use `RepositorySystem` instances. The `RepositorySystemSession` should be -created using the `org.apache.maven.repository.internal.MavenRepositorySystemUtils#newSession()` method +and supplies new, ready-to-use `RepositorySystem` instance for each call. Class is intentionally simplistic, +no instance caching or anything alike is present: all that is concern of caller, just like proper shutdown +of the created resolver instances is. + +The `RepositorySystemSession` should be created using the +`org.apache.maven.repository.internal.MavenRepositorySystemUtils#newSession()` method and local repository added to it in usual way (there is no change in this area). The supplier class is written in a way, to allow easy customization if needed: just extend the class and override @@ -47,7 +51,10 @@ logging purposes, but this module does NOT provide any implementation for it as It is the consumer/user obligation to provide one at runtime. Version of `maven-resolver-supplier` artifact in use **must be strictly aligned** with other Resolver artifacts -on classpath. +on classpath and Maven version. + +An example usage (and customization) of supplier can be seen in +[Maven Resolver Ant Tasks 1.5.0](https://github.com/apache/maven-resolver-ant-tasks/blob/maven-resolver-ant-tasks-1.5.0/src/main/java/org/apache/maven/resolver/internal/ant/AntRepositorySystemSupplier.java). ## Resolver configuration @@ -60,7 +67,7 @@ The supplier will provide fully usable instance. To configure resolver, use sess configuration) properties, when constructing session. All the configuration options are available as [listed here](https://maven.apache.org/resolver/configuration.html). -## Extending Resolver +## Extending Supplied Resolver Extending supplied resolver is simple, and basically requires same three steps for whatever extra you want to include (like Wagon transport, distributed locking, etc). From 67b25525ca7693ed27b0f25ba1bb9a033ba58727 Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Thu, 12 Oct 2023 22:57:57 +0200 Subject: [PATCH 20/23] [MRESOLVER-408] Make master 2.0.0-SNAPSHOT (#335) Changes: * make version 2.0.0-SNAPSHOT * build time JDK requirement: raise to 11 (raise as needed, preferably use LTS versions) * existing modules are `release=8` * drop animal sniffer * redefine enforceBytecodeVersion: we do produce Java 8 stuff, but for **testing** we may want and will want to use something that is 8+ (ie. Jetty 12) * fix sisu (was invoked twice, last parent POM update) * compiler: proactively disable annotation processing (we do not use those, but Sisu APT is present, we do not want it auto-picked up, we explicitly index using sisu mojo) * compiler: be chatty about deprecations, to help us down the line removing them --- https://issues.apache.org/jira/browse/MRESOLVER-408 --- .github/workflows/maven-verify.yml | 2 +- Jenkinsfile | 4 +- maven-resolver-api/pom.xml | 2 +- maven-resolver-connector-basic/pom.xml | 2 +- .../maven-resolver-demo-maven-plugin/pom.xml | 2 +- .../maven-resolver-demo-snippets/pom.xml | 2 +- maven-resolver-demos/pom.xml | 2 +- maven-resolver-impl/pom.xml | 2 +- maven-resolver-named-locks-hazelcast/pom.xml | 2 +- maven-resolver-named-locks-redisson/pom.xml | 2 +- maven-resolver-named-locks/pom.xml | 2 +- maven-resolver-spi/pom.xml | 2 +- maven-resolver-supplier/pom.xml | 2 +- maven-resolver-test-util/pom.xml | 2 +- maven-resolver-transport-classpath/pom.xml | 2 +- maven-resolver-transport-file/pom.xml | 2 +- maven-resolver-transport-http/pom.xml | 2 +- maven-resolver-transport-wagon/pom.xml | 2 +- maven-resolver-util/pom.xml | 2 +- pom.xml | 107 ++++++++++++------ src/site/markdown/upgrading-resolver.md | 26 +++++ src/site/site.xml | 1 + 22 files changed, 116 insertions(+), 58 deletions(-) create mode 100644 src/site/markdown/upgrading-resolver.md diff --git a/.github/workflows/maven-verify.yml b/.github/workflows/maven-verify.yml index dbdabb6f1..be6eeb616 100644 --- a/.github/workflows/maven-verify.yml +++ b/.github/workflows/maven-verify.yml @@ -27,5 +27,5 @@ jobs: uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify.yml@v3 with: ff-site-run: false - + jdk-matrix: '[ "11", "17", "21" ]' diff --git a/Jenkinsfile b/Jenkinsfile index d89f893d1..ef5393dda 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -17,7 +17,5 @@ * under the License. */ -// Currently we can only build with JDK8+ based on the usage -// of bnd-maven-plugin. -asfMavenTlpStdBuild( 'jdks' : [ "8", "11", "17" ] ) +asfMavenTlpStdBuild( 'jdks' : [ "11", "17", "21" ] ) diff --git a/maven-resolver-api/pom.xml b/maven-resolver-api/pom.xml index 1d9773a80..c3a9991c0 100644 --- a/maven-resolver-api/pom.xml +++ b/maven-resolver-api/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver - 1.9.17-SNAPSHOT + 2.0.0-SNAPSHOT maven-resolver-api diff --git a/maven-resolver-connector-basic/pom.xml b/maven-resolver-connector-basic/pom.xml index e9061dd67..f7dff4654 100644 --- a/maven-resolver-connector-basic/pom.xml +++ b/maven-resolver-connector-basic/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver - 1.9.17-SNAPSHOT + 2.0.0-SNAPSHOT maven-resolver-connector-basic diff --git a/maven-resolver-demos/maven-resolver-demo-maven-plugin/pom.xml b/maven-resolver-demos/maven-resolver-demo-maven-plugin/pom.xml index 15efba65a..620acbabd 100644 --- a/maven-resolver-demos/maven-resolver-demo-maven-plugin/pom.xml +++ b/maven-resolver-demos/maven-resolver-demo-maven-plugin/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver-demos - 1.9.17-SNAPSHOT + 2.0.0-SNAPSHOT resolver-demo-maven-plugin diff --git a/maven-resolver-demos/maven-resolver-demo-snippets/pom.xml b/maven-resolver-demos/maven-resolver-demo-snippets/pom.xml index d36ccc2d1..bdc1dc2e8 100644 --- a/maven-resolver-demos/maven-resolver-demo-snippets/pom.xml +++ b/maven-resolver-demos/maven-resolver-demo-snippets/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver-demos - 1.9.17-SNAPSHOT + 2.0.0-SNAPSHOT maven-resolver-demo-snippets diff --git a/maven-resolver-demos/pom.xml b/maven-resolver-demos/pom.xml index b1de669e9..9342a7961 100644 --- a/maven-resolver-demos/pom.xml +++ b/maven-resolver-demos/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver - 1.9.17-SNAPSHOT + 2.0.0-SNAPSHOT maven-resolver-demos diff --git a/maven-resolver-impl/pom.xml b/maven-resolver-impl/pom.xml index 98bf1c8a1..64614cb9d 100644 --- a/maven-resolver-impl/pom.xml +++ b/maven-resolver-impl/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver - 1.9.17-SNAPSHOT + 2.0.0-SNAPSHOT maven-resolver-impl diff --git a/maven-resolver-named-locks-hazelcast/pom.xml b/maven-resolver-named-locks-hazelcast/pom.xml index 3c9d32f42..074417c87 100644 --- a/maven-resolver-named-locks-hazelcast/pom.xml +++ b/maven-resolver-named-locks-hazelcast/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver - 1.9.17-SNAPSHOT + 2.0.0-SNAPSHOT maven-resolver-named-locks-hazelcast diff --git a/maven-resolver-named-locks-redisson/pom.xml b/maven-resolver-named-locks-redisson/pom.xml index cf8840fd6..ef8aab3f0 100644 --- a/maven-resolver-named-locks-redisson/pom.xml +++ b/maven-resolver-named-locks-redisson/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver - 1.9.17-SNAPSHOT + 2.0.0-SNAPSHOT maven-resolver-named-locks-redisson diff --git a/maven-resolver-named-locks/pom.xml b/maven-resolver-named-locks/pom.xml index 177d897d7..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.17-SNAPSHOT + 2.0.0-SNAPSHOT maven-resolver-named-locks diff --git a/maven-resolver-spi/pom.xml b/maven-resolver-spi/pom.xml index af2c1fcf1..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.17-SNAPSHOT + 2.0.0-SNAPSHOT maven-resolver-spi diff --git a/maven-resolver-supplier/pom.xml b/maven-resolver-supplier/pom.xml index e6e7c8c0a..fee4e6e2a 100644 --- a/maven-resolver-supplier/pom.xml +++ b/maven-resolver-supplier/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver - 1.9.17-SNAPSHOT + 2.0.0-SNAPSHOT maven-resolver-supplier diff --git a/maven-resolver-test-util/pom.xml b/maven-resolver-test-util/pom.xml index 5a709dad5..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.17-SNAPSHOT + 2.0.0-SNAPSHOT maven-resolver-test-util diff --git a/maven-resolver-transport-classpath/pom.xml b/maven-resolver-transport-classpath/pom.xml index 694e85b6d..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.17-SNAPSHOT + 2.0.0-SNAPSHOT maven-resolver-transport-classpath diff --git a/maven-resolver-transport-file/pom.xml b/maven-resolver-transport-file/pom.xml index 024591eff..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.17-SNAPSHOT + 2.0.0-SNAPSHOT maven-resolver-transport-file diff --git a/maven-resolver-transport-http/pom.xml b/maven-resolver-transport-http/pom.xml index e087f0e7b..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.17-SNAPSHOT + 2.0.0-SNAPSHOT maven-resolver-transport-http diff --git a/maven-resolver-transport-wagon/pom.xml b/maven-resolver-transport-wagon/pom.xml index 5985df226..bb37726d8 100644 --- a/maven-resolver-transport-wagon/pom.xml +++ b/maven-resolver-transport-wagon/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver - 1.9.17-SNAPSHOT + 2.0.0-SNAPSHOT maven-resolver-transport-wagon diff --git a/maven-resolver-util/pom.xml b/maven-resolver-util/pom.xml index cfaec8d0d..4ef5e8e8c 100644 --- a/maven-resolver-util/pom.xml +++ b/maven-resolver-util/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.resolver maven-resolver - 1.9.17-SNAPSHOT + 2.0.0-SNAPSHOT maven-resolver-util diff --git a/pom.xml b/pom.xml index 2538a4331..b04ff0f75 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ org.apache.maven.resolver maven-resolver - 1.9.17-SNAPSHOT + 2.0.0-SNAPSHOT pom Maven Artifact Resolver @@ -85,18 +85,19 @@ 8 + ${javaVersion} true ${surefire.redirectTestOutputToFile} resolver-archives/resolver-LATEST None - 0.3.5 - 5.1.0 + 0.9.0.M2 + 6.0.0 1.7.36 3.9.5 - [3.8.7,) - [1.8.0-362,) - 2023-09-22T18:13:46Z + [3.8.8,) + [11.0.20,) + 2023-10-10T21:40:45Z @@ -305,6 +306,27 @@ + + org.apache.maven.plugins + maven-enforcer-plugin + + + enforce-bytecode-version + + enforce + + + + + ${maven.compiler.release} + test + + + true + + + + org.apache.maven.plugins maven-javadoc-plugin @@ -429,20 +451,6 @@ - - org.eclipse.sisu - sisu-maven-plugin - ${sisuVersion} - - - generate-index - - main-index - - process-classes - - - org.apache.rat apache-rat-plugin @@ -486,29 +494,54 @@ + + + com.diffplug.spotless + spotless-maven-plugin + 2.40.0 + + + + + + 2.38.0 + + + + config/maven-eclipse-importorder.txt + + + config/maven-header-plain.txt + + + + + false + + true + + + + true + + + - org.codehaus.mojo - animal-sniffer-maven-plugin - 1.23 + org.apache.maven.plugins + maven-compiler-plugin - - org.codehaus.mojo.signature - java18 - 1.0 - + none + + -Xlint:deprecation + - - - check-java-compat - - check - - process-classes - - + + + org.eclipse.sisu + sisu-maven-plugin diff --git a/src/site/markdown/upgrading-resolver.md b/src/site/markdown/upgrading-resolver.md new file mode 100644 index 000000000..454bbbefb --- /dev/null +++ b/src/site/markdown/upgrading-resolver.md @@ -0,0 +1,26 @@ +# Upgrading Resolver (major versions) + + +This page will collect quick guides for developers upgrading from one to +another major version of Resolver. + +# Upgrading from 1.x to 2.x + +Maven Resolver upcoming major version 2.x should be "smooth sailing", as long you +do not depend (directly or indirectly) on **deprecated** classes from Resolver +1.x line. Always use latest 1.x release to check for deprecated classes. diff --git a/src/site/site.xml b/src/site/site.xml index fdb5af531..d289dba5f 100644 --- a/src/site/site.xml +++ b/src/site/site.xml @@ -33,6 +33,7 @@ under the License. + From 3a5c8b0b668a14c4d27c15dd5e8776061e86819b Mon Sep 17 00:00:00 2001 From: Eric Cai Date: Fri, 13 Oct 2023 05:28:20 +0800 Subject: [PATCH 21/23] [MRESOLVER-324] Make bf option as default (#325) Make new BF resolver the default. --- https://issues.apache.org/jira/browse/MRESOLVER-324 --- .../internal/impl/collect/DefaultDependencyCollector.java | 2 +- src/site/markdown/configuration.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/collect/DefaultDependencyCollector.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/collect/DefaultDependencyCollector.java index b468e7faa..b3e9704bb 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/collect/DefaultDependencyCollector.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/collect/DefaultDependencyCollector.java @@ -46,7 +46,7 @@ public class DefaultDependencyCollector implements DependencyCollector, Service { private static final String CONFIG_PROP_COLLECTOR_IMPL = "aether.dependencyCollector.impl"; - private static final String DEFAULT_COLLECTOR_IMPL = DfDependencyCollector.NAME; + private static final String DEFAULT_COLLECTOR_IMPL = BfDependencyCollector.NAME; private final Map delegates; diff --git a/src/site/markdown/configuration.md b/src/site/markdown/configuration.md index fbee0a98e..de1e60708 100644 --- a/src/site/markdown/configuration.md +++ b/src/site/markdown/configuration.md @@ -64,7 +64,7 @@ Option | Type | Description | Default Value | Supports Repo ID Suffix `aether.connector.wagon.config` | Object | The configuration to use for the Wagon provider. | - | yes (must be used) `aether.dependencyCollector.maxCycles` | int | Only up to the given amount cyclic dependencies are emitted. | `10` | no `aether.dependencyCollector.maxExceptions` | int | Only exceptions up to the number given in this configuration property are emitted. Exceptions which exceed that number are swallowed. | `50` | no -`aether.dependencyCollector.impl` | String | The name of the dependency collector implementation to use: depth-first (original) named `df`, and breadth-first (new in 1.8.0) named `bf`. Both collectors produce equivalent results, but they may differ performance wise, depending on project being applied to. Our experience shows that existing `df` is well suited for smaller to medium size projects, while `bf` may perform better on huge projects with many dependencies. Experiment (and come back to us!) to figure out which one suits you the better. | `"df"` | no +`aether.dependencyCollector.impl` | String | The name of the dependency collector implementation to use: depth-first (original) named `df`, and breadth-first (new in 1.8.0) named `bf`. Both collectors produce equivalent results, but they may differ performance wise, depending on project being applied to. Our experience shows that existing `df` is well suited for smaller to medium size projects, while `bf` may perform better on huge projects with many dependencies. Experiment (and come back to us!) to figure out which one suits you the better. | `"bf"` | no `aether.dependencyCollector.bf.skipper` | boolean | Flag controlling whether to skip resolving duplicate/conflicting nodes during the breadth-first (`bf`) dependency collection process. | `true` | no `aether.dependencyCollector.bf.threads` or `maven.artifact.threads` | int | Number of threads to use for collecting POMs and version ranges in BF collector. | `5` | no `aether.dependencyCollector.pool.artifact` | String | Flag controlling interning data pool type used by dependency collector for Artifact instances, matters for heap consumption. By default uses "weak" references (consume less heap). Using "hard" will make it much more memory aggressive and possibly faster (system and Java dependent). Supported values: `"hard"`, `"weak"`. | `"weak"` | no From 0b919cd930afa47fe1e5b219f17597d612515ef1 Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Thu, 12 Oct 2023 23:30:00 +0200 Subject: [PATCH 22/23] Lax Java 11 enforcer Seems ASF Infra is lagging :( --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b04ff0f75..ea95b910e 100644 --- a/pom.xml +++ b/pom.xml @@ -96,7 +96,7 @@ 3.9.5 [3.8.8,) - [11.0.20,) + [11.0.16,) 2023-10-10T21:40:45Z From aa3945e00d90a06c17f230c270a71563357eeca8 Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Fri, 13 Oct 2023 22:38:38 +0200 Subject: [PATCH 23/23] [MRESOLVER-377] Introduce metadataUpdatePolicy (#308) Split the policies applied in case of data and metadata, allowing greater control of their updates. Still, work "as before" in case of applications that migrate from 1.x resolver (they should receive no behavior change). The crux of this change is really just to introduce two policies (to co-exist in parallel), but if application using resolver decides to use same policy for both, the original behavior of resolver returns and will seemingly behave as before (ie. like 1.9.x does). Maven relies on metadata in these cases ONLY: * resolving maven plugin prefix to maven plugin groupId (G level md) * resolving snapshot version to timestamped version (V level md) Resolver OTOH provides one more use case: * "discovery" of existing versions for given GA (this use case is NOT used in Maven Core) (A level md) Now, while Maven Core itself does NOT use 3rd use case, some plugins does, most notably the versions-maven-plugin. Today, everyone on Earth use this plugin along with `-U` Maven switch to pick up new stuff from remote repository, but this is total overkill, as it refreshes _everything_ (yes, even the immutable release artifacts!). The `-U` is simply a "must", to make Maven "refresh metadata" (as well, along with all the Artifacts) to pick up new versions on remote. Versions plugin did implement a ["hack" to overcome this limitation](https://github.com/mojohaus/versions/commit/82e2450d8bbd22c3f8cdc06d44c44d618c69e23e), that is still a hack, as it still applies to everything. Proper solution is to have means to express `-U but for metadata only`. This PR makes this possible on resolver side. --- https://issues.apache.org/jira/browse/MRESOLVER-377 --- ...ractForwardingRepositorySystemSession.java | 5 +++ .../DefaultRepositorySystemSession.java | 25 +++++++++++ .../aether/RepositorySystemSession.java | 14 ++++++- .../aether/repository/RepositoryPolicy.java | 39 ++++++++++++++---- .../org/eclipse/aether/impl/UpdateCheck.java | 34 +++++++++++++-- .../impl/DefaultArtifactResolver.java | 1 + .../impl/DefaultMetadataResolver.java | 6 ++- .../impl/DefaultRemoteRepositoryManager.java | 41 +++++++++++++++---- .../impl/DefaultUpdateCheckManager.java | 10 +++-- .../impl/DefaultUpdateCheckManagerTest.java | 6 +++ 10 files changed, 155 insertions(+), 26 deletions(-) diff --git a/maven-resolver-api/src/main/java/org/eclipse/aether/AbstractForwardingRepositorySystemSession.java b/maven-resolver-api/src/main/java/org/eclipse/aether/AbstractForwardingRepositorySystemSession.java index a1a2083e1..4583b065c 100644 --- a/maven-resolver-api/src/main/java/org/eclipse/aether/AbstractForwardingRepositorySystemSession.java +++ b/maven-resolver-api/src/main/java/org/eclipse/aether/AbstractForwardingRepositorySystemSession.java @@ -87,6 +87,11 @@ public String getUpdatePolicy() { return getSession().getUpdatePolicy(); } + @Override + public String getMetadataUpdatePolicy() { + return getSession().getMetadataUpdatePolicy(); + } + @Override public LocalRepository getLocalRepository() { return getSession().getLocalRepository(); diff --git a/maven-resolver-api/src/main/java/org/eclipse/aether/DefaultRepositorySystemSession.java b/maven-resolver-api/src/main/java/org/eclipse/aether/DefaultRepositorySystemSession.java index a6e24fd57..9738d9a07 100644 --- a/maven-resolver-api/src/main/java/org/eclipse/aether/DefaultRepositorySystemSession.java +++ b/maven-resolver-api/src/main/java/org/eclipse/aether/DefaultRepositorySystemSession.java @@ -73,6 +73,8 @@ public final class DefaultRepositorySystemSession implements RepositorySystemSes private String updatePolicy; + private String metadataUpdatePolicy; + private LocalRepositoryManager localRepositoryManager; private FileTransformerManager fileTransformerManager; @@ -154,6 +156,7 @@ public DefaultRepositorySystemSession(RepositorySystemSession session) { setArtifactDescriptorPolicy(session.getArtifactDescriptorPolicy()); setChecksumPolicy(session.getChecksumPolicy()); setUpdatePolicy(session.getUpdatePolicy()); + setMetadataUpdatePolicy(session.getMetadataUpdatePolicy()); setLocalRepositoryManager(session.getLocalRepositoryManager()); setWorkspaceReader(session.getWorkspaceReader()); setRepositoryListener(session.getRepositoryListener()); @@ -293,6 +296,28 @@ public DefaultRepositorySystemSession setUpdatePolicy(String updatePolicy) { return this; } + @Override + public String getMetadataUpdatePolicy() { + return metadataUpdatePolicy; + } + + /** + * Sets the global metadata update policy. If set, the global update policy overrides the update policies of the remote + * repositories being used for resolution. + * + * @param metadataUpdatePolicy The global update policy, may be {@code null}/empty to apply the per-repository policies. + * @return This session for chaining, never {@code null}. + * @see RepositoryPolicy#UPDATE_POLICY_ALWAYS + * @see RepositoryPolicy#UPDATE_POLICY_DAILY + * @see RepositoryPolicy#UPDATE_POLICY_NEVER + * @since TBD + */ + public DefaultRepositorySystemSession setMetadataUpdatePolicy(String metadataUpdatePolicy) { + verifyStateForMutation(); + this.metadataUpdatePolicy = metadataUpdatePolicy; + return this; + } + @Override public LocalRepository getLocalRepository() { LocalRepositoryManager lrm = getLocalRepositoryManager(); diff --git a/maven-resolver-api/src/main/java/org/eclipse/aether/RepositorySystemSession.java b/maven-resolver-api/src/main/java/org/eclipse/aether/RepositorySystemSession.java index 31e99cd70..581161119 100644 --- a/maven-resolver-api/src/main/java/org/eclipse/aether/RepositorySystemSession.java +++ b/maven-resolver-api/src/main/java/org/eclipse/aether/RepositorySystemSession.java @@ -94,7 +94,7 @@ public interface RepositorySystemSession { String getChecksumPolicy(); /** - * Gets the global update policy. If set, the global update policy overrides the update policies of the remote + * Gets the global data update policy. If set, the global update policy overrides the update policies of the remote * repositories being used for resolution. * * @return The global update policy or {@code null}/empty if not set and the per-repository policies apply. @@ -104,6 +104,18 @@ public interface RepositorySystemSession { */ String getUpdatePolicy(); + /** + * Gets the global metadata update policy. If set, the global update policy overrides the update policies of the remote + * repositories being used for resolution. + * + * @return The global update policy or {@code null}/empty if not set and the per-repository policies apply. + * @see RepositoryPolicy#UPDATE_POLICY_ALWAYS + * @see RepositoryPolicy#UPDATE_POLICY_DAILY + * @see RepositoryPolicy#UPDATE_POLICY_NEVER + * @since TBD + */ + String getMetadataUpdatePolicy(); + /** * Gets the local repository used during this session. This is a convenience method for * {@link LocalRepositoryManager#getRepository()}. diff --git a/maven-resolver-api/src/main/java/org/eclipse/aether/repository/RepositoryPolicy.java b/maven-resolver-api/src/main/java/org/eclipse/aether/repository/RepositoryPolicy.java index 14f44d44d..6adf28bf6 100644 --- a/maven-resolver-api/src/main/java/org/eclipse/aether/repository/RepositoryPolicy.java +++ b/maven-resolver-api/src/main/java/org/eclipse/aether/repository/RepositoryPolicy.java @@ -62,13 +62,23 @@ public final class RepositoryPolicy { private final String updatePolicy; + private final String metadataUpdatePolicy; + private final String checksumPolicy; /** * Creates a new policy with checksum warnings and daily update checks. */ public RepositoryPolicy() { - this(true, UPDATE_POLICY_DAILY, CHECKSUM_POLICY_WARN); + this(true, UPDATE_POLICY_DAILY, UPDATE_POLICY_DAILY, CHECKSUM_POLICY_WARN); + } + + /** + * Creates a new policy with the specified settings (uses same update policy for data and metadata, retains old + * resolver behaviour). + */ + public RepositoryPolicy(boolean enabled, String updatePolicy, String checksumPolicy) { + this(enabled, updatePolicy, updatePolicy, checksumPolicy); } /** @@ -76,12 +86,16 @@ public RepositoryPolicy() { * * @param enabled A flag whether the associated repository should be accessed or not. * @param updatePolicy The update interval after which locally cached data from the repository is considered stale - * and should be refetched, may be {@code null}. + * and should be re-fetched, may be {@code null}. + * @param metadataUpdatePolicy The update interval after which locally cached metadata from the repository is considered stale + * and should be re-fetched, may be {@code null}. * @param checksumPolicy The way checksum verification should be handled, may be {@code null}. + * @since TBD */ - public RepositoryPolicy(boolean enabled, String updatePolicy, String checksumPolicy) { + public RepositoryPolicy(boolean enabled, String updatePolicy, String metadataUpdatePolicy, String checksumPolicy) { this.enabled = enabled; this.updatePolicy = (updatePolicy != null) ? updatePolicy : ""; + this.metadataUpdatePolicy = (metadataUpdatePolicy != null) ? metadataUpdatePolicy : ""; this.checksumPolicy = (checksumPolicy != null) ? checksumPolicy : ""; } @@ -103,6 +117,16 @@ public String getUpdatePolicy() { return updatePolicy; } + /** + * Gets the update policy for locally cached metadata from the repository. + * + * @return The update policy, never {@code null}. + * @since TBD + */ + public String getMetadataUpdatePolicy() { + return metadataUpdatePolicy; + } + /** * Gets the policy for checksum validation. * @@ -114,11 +138,10 @@ public String getChecksumPolicy() { @Override public String toString() { - StringBuilder buffer = new StringBuilder(256); - buffer.append("enabled=").append(isEnabled()); - buffer.append(", checksums=").append(getChecksumPolicy()); - buffer.append(", updates=").append(getUpdatePolicy()); - return buffer.toString(); + return "enabled=" + isEnabled() + + ", checksums=" + getChecksumPolicy() + + ", updates=" + getUpdatePolicy() + + ", metadataUpdates=" + getMetadataUpdatePolicy(); } @Override diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/impl/UpdateCheck.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/impl/UpdateCheck.java index f689c12fe..f5a2454e9 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/impl/UpdateCheck.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/impl/UpdateCheck.java @@ -43,6 +43,8 @@ public final class UpdateCheck { private String policy; + private String metadataPolicy; + private RemoteRepository repository; private RemoteRepository authoritativeRepository; @@ -147,19 +149,30 @@ public UpdateCheck setFileValid(boolean fileValid) { } /** - * Gets the policy to use for the check. + * Gets the policy to use for the data check. * - * @return The policy to use for the check. + * @return The policy to use for the data check. * @see org.eclipse.aether.repository.RepositoryPolicy */ public String getPolicy() { return policy; } + /** + * Gets the policy to use for the metadata check. + * + * @return The policy to use for the metadata check. + * @see org.eclipse.aether.repository.RepositoryPolicy + * @since TBD + */ + public String getMetadataPolicy() { + return metadataPolicy; + } + /** * Sets the policy to use for the check. * - * @param policy The policy to use for the check, may be {@code null}. + * @param policy The policy to use for the data check, may be {@code null}. * @return This object for chaining. * @see org.eclipse.aether.repository.RepositoryPolicy */ @@ -168,6 +181,19 @@ public UpdateCheck setPolicy(String policy) { return this; } + /** + * Sets the policy to use for the check. + * + * @param metadataPolicy The policy to use for the metadata check, may be {@code null}. + * @return This object for chaining. + * @see org.eclipse.aether.repository.RepositoryPolicy + * @since TBD + */ + public UpdateCheck setMetadataPolicy(String metadataPolicy) { + this.metadataPolicy = metadataPolicy; + return this; + } + /** * Gets the repository from which a potential update/download will performed. * @@ -256,6 +282,6 @@ public UpdateCheck setException(E exception) { @Override public String toString() { - return getPolicy() + ": " + getFile() + " < " + getRepository(); + return getPolicy() + "/" + getMetadataPolicy() + ": " + getFile() + " < " + getRepository(); } } diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultArtifactResolver.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultArtifactResolver.java index 044302461..164d42557 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultArtifactResolver.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultArtifactResolver.java @@ -582,6 +582,7 @@ private List gatherDownloads(RepositorySystemSession session, check.setFileValid(false); check.setRepository(group.repository); check.setPolicy(policy.getUpdatePolicy()); + check.setMetadataPolicy(policy.getMetadataUpdatePolicy()); item.updateCheck = check; updateCheckManager.checkArtifact(session, check); if (!check.isRequired()) { diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultMetadataResolver.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultMetadataResolver.java index b0620cd7b..b26de1d8d 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultMetadataResolver.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultMetadataResolver.java @@ -282,6 +282,8 @@ private List resolve( List> checks = new ArrayList<>(); Exception exception = null; for (RemoteRepository repo : repositories) { + RepositoryPolicy policy = getPolicy(session, repo, metadata.getNature()); + UpdateCheck check = new UpdateCheck<>(); check.setLocalLastUpdated((localLastUpdate != null) ? localLastUpdate : 0); check.setItem(metadata); @@ -294,8 +296,8 @@ private List resolve( check.setFile(checkFile); check.setRepository(repository); check.setAuthoritativeRepository(repo); - check.setPolicy( - getPolicy(session, repo, metadata.getNature()).getUpdatePolicy()); + check.setPolicy(policy.getUpdatePolicy()); + check.setMetadataPolicy(policy.getMetadataUpdatePolicy()); if (lrmResult.isStale()) { checks.add(check); diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRemoteRepositoryManager.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRemoteRepositoryManager.java index 9f8471ee4..7844bc57d 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRemoteRepositoryManager.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRemoteRepositoryManager.java @@ -256,25 +256,41 @@ private RepositoryPolicy merge( if (policy2 == null) { if (globalPolicy) { - policy = merge(policy1, session.getUpdatePolicy(), session.getChecksumPolicy()); + policy = merge( + policy1, + session.getUpdatePolicy(), + session.getMetadataUpdatePolicy(), + session.getChecksumPolicy()); } else { policy = policy1; } } else if (policy1 == null) { if (globalPolicy) { - policy = merge(policy2, session.getUpdatePolicy(), session.getChecksumPolicy()); + policy = merge( + policy2, + session.getUpdatePolicy(), + session.getMetadataUpdatePolicy(), + session.getChecksumPolicy()); } else { policy = policy2; } } else if (!policy2.isEnabled()) { if (globalPolicy) { - policy = merge(policy1, session.getUpdatePolicy(), session.getChecksumPolicy()); + policy = merge( + policy1, + session.getUpdatePolicy(), + session.getMetadataUpdatePolicy(), + session.getChecksumPolicy()); } else { policy = policy1; } } else if (!policy1.isEnabled()) { if (globalPolicy) { - policy = merge(policy2, session.getUpdatePolicy(), session.getChecksumPolicy()); + policy = merge( + policy2, + session.getUpdatePolicy(), + session.getMetadataUpdatePolicy(), + session.getChecksumPolicy()); } else { policy = policy2; } @@ -296,24 +312,35 @@ private RepositoryPolicy merge( updates = updatePolicyAnalyzer.getEffectiveUpdatePolicy( session, policy1.getUpdatePolicy(), policy2.getUpdatePolicy()); } + String metadataUpdates = session.getMetadataUpdatePolicy(); + if (globalPolicy && metadataUpdates != null && !metadataUpdates.isEmpty()) { + // use global override + } else { + metadataUpdates = updatePolicyAnalyzer.getEffectiveUpdatePolicy( + session, policy1.getMetadataUpdatePolicy(), policy2.getMetadataUpdatePolicy()); + } - policy = new RepositoryPolicy(true, updates, checksums); + policy = new RepositoryPolicy(true, updates, metadataUpdates, checksums); } return policy; } - private RepositoryPolicy merge(RepositoryPolicy policy, String updates, String checksums) { + private RepositoryPolicy merge(RepositoryPolicy policy, String updates, String metadataUpdates, String checksums) { if (policy != null) { if (updates == null || updates.isEmpty()) { updates = policy.getUpdatePolicy(); } + if (metadataUpdates == null || metadataUpdates.isEmpty()) { + metadataUpdates = policy.getMetadataUpdatePolicy(); + } if (checksums == null || checksums.isEmpty()) { checksums = policy.getChecksumPolicy(); } if (!policy.getUpdatePolicy().equals(updates) + || !policy.getMetadataUpdatePolicy().equals(metadataUpdates) || !policy.getChecksumPolicy().equals(checksums)) { - policy = new RepositoryPolicy(policy.isEnabled(), updates, checksums); + policy = new RepositoryPolicy(policy.isEnabled(), updates, metadataUpdates, checksums); } } return policy; diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultUpdateCheckManager.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultUpdateCheckManager.java index 50a960bfa..27ec290fb 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultUpdateCheckManager.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultUpdateCheckManager.java @@ -136,8 +136,9 @@ public DefaultUpdateCheckManager setUpdatePolicyAnalyzer(UpdatePolicyAnalyzer up public void checkArtifact(RepositorySystemSession session, UpdateCheck check) { requireNonNull(session, "session cannot be null"); requireNonNull(check, "check cannot be null"); + final String updatePolicy = check.getPolicy(); if (check.getLocalLastUpdated() != 0 - && !isUpdatedRequired(session, check.getLocalLastUpdated(), check.getPolicy())) { + && !isUpdatedRequired(session, check.getLocalLastUpdated(), updatePolicy)) { LOGGER.debug("Skipped remote request for {}, locally installed artifact up-to-date", check.getItem()); check.setRequired(false); @@ -187,7 +188,7 @@ public void checkArtifact(RepositorySystemSession session, UpdateCheck check) { requireNonNull(session, "session cannot be null"); requireNonNull(check, "check cannot be null"); + final String updatePolicy = check.getMetadataPolicy(); if (check.getLocalLastUpdated() != 0 - && !isUpdatedRequired(session, check.getLocalLastUpdated(), check.getPolicy())) { + && !isUpdatedRequired(session, check.getLocalLastUpdated(), updatePolicy)) { LOGGER.debug("Skipped remote request for {} locally installed metadata up-to-date", check.getItem()); check.setRequired(false); @@ -292,7 +294,7 @@ public void checkMetadata(RepositorySystemSession session, UpdateCheck newMetadataCheck() { check.setRepository(repository); check.setAuthoritativeRepository(repository); check.setPolicy(RepositoryPolicy.UPDATE_POLICY_INTERVAL + ":10"); + check.setMetadataPolicy(RepositoryPolicy.UPDATE_POLICY_INTERVAL + ":10"); return check; } @@ -298,6 +299,7 @@ public void testCheckMetadataErrorFromRepoCachingDisabled() { public void testCheckMetadataAtMostOnceDuringSessionEvenIfUpdatePolicyAlways() { UpdateCheck check = newMetadataCheck(); check.setPolicy(RepositoryPolicy.UPDATE_POLICY_ALWAYS); + check.setMetadataPolicy(RepositoryPolicy.UPDATE_POLICY_ALWAYS); // first check manager.checkMetadata(session, check); @@ -314,6 +316,7 @@ public void testCheckMetadataAtMostOnceDuringSessionEvenIfUpdatePolicyAlways() { public void testCheckMetadataSessionStateModes() { UpdateCheck check = newMetadataCheck(); check.setPolicy(RepositoryPolicy.UPDATE_POLICY_ALWAYS); + check.setMetadataPolicy(RepositoryPolicy.UPDATE_POLICY_ALWAYS); manager.touchMetadata(session, check); session.setConfigProperty(DefaultUpdateCheckManager.CONFIG_PROP_SESSION_STATE, "bypass"); @@ -338,6 +341,7 @@ public void testCheckMetadataSessionStateModes() { public void testCheckMetadataAtMostOnceDuringSessionEvenIfUpdatePolicyAlways_InvalidFile() { UpdateCheck check = newMetadataCheck(); check.setPolicy(RepositoryPolicy.UPDATE_POLICY_ALWAYS); + check.setMetadataPolicy(RepositoryPolicy.UPDATE_POLICY_ALWAYS); check.setFileValid(false); // first check @@ -364,6 +368,7 @@ public void testCheckMetadataAtMostOnceDuringSessionEvenIfUpdatePolicyAlways_Inv public void testCheckMetadataAtMostOnceDuringSessionEvenIfUpdatePolicyAlways_DifferentRepoIdSameUrl() { UpdateCheck check = newMetadataCheck(); check.setPolicy(RepositoryPolicy.UPDATE_POLICY_ALWAYS); + check.setMetadataPolicy(RepositoryPolicy.UPDATE_POLICY_ALWAYS); check.setFileValid(false); // first check @@ -427,6 +432,7 @@ public void testCheckMetadataWhenLocallyDeletedEvenIfTimestampUpToDate() { public void testCheckMetadataNotWhenUpdatePolicyIsNeverAndTimestampIsUnavailable() { UpdateCheck check = newMetadataCheck(); check.setPolicy(RepositoryPolicy.UPDATE_POLICY_NEVER); + check.setMetadataPolicy(RepositoryPolicy.UPDATE_POLICY_NEVER); session.setResolutionErrorPolicy(new SimpleResolutionErrorPolicy(true, false)); manager.checkMetadata(session, check);