You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by cs...@apache.org on 2022/06/24 10:41:53 UTC

[maven] 01/01: WIP

This is an automated email from the ASF dual-hosted git repository.

cstamas pushed a commit to branch resolver-locking-mode
in repository https://gitbox.apache.org/repos/asf/maven.git

commit 9e4b124af59fa28f38cb931cc51a9b1bbd31847d
Author: Tamas Cservenak <ta...@cservenak.net>
AuthorDate: Wed Jun 22 22:03:24 2022 +0200

    WIP
---
 .../DefaultRepositorySystemSessionFactory.java     | 33 ++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java b/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java
index 40f3592a5..8b73a7a85 100644
--- a/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java
+++ b/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java
@@ -81,6 +81,20 @@ public class DefaultRepositorySystemSessionFactory
 
     private static final String RESOLVER_MAX_PRIORITY = String.valueOf( Float.MAX_VALUE );
 
+    private static final String MAVEN_RESOLVER_LOCKING_KEY = "maven.resolver.locking";
+
+    private static final String MAVEN_RESOLVER_LOCKING_DEFAULT = "default";
+
+    private static final String MAVEN_RESOLVER_LOCKING_LOCAL = "local";
+
+    private static final String MAVEN_RESOLVER_LOCKING_FILE = "file";
+
+    private static final String MAVEN_RESOLVER_LOCKING_AUTO = "auto";
+
+    private static final String MAVEN_RESOLVER_LOCKING_LOCK_FACTORY_KEY = "aether.syncContext.named.factory";
+
+    private static final String MAVEN_RESOLVER_LOCKING_NAME_MAPPER_KEY = "aether.syncContext.named.nameMapper";
+
     @Inject
     private Logger logger;
 
@@ -282,6 +296,25 @@ public class DefaultRepositorySystemSessionFactory
                     + MAVEN_RESOLVER_TRANSPORT_NATIVE + ", " + MAVEN_RESOLVER_TRANSPORT_AUTO );
         }
 
+        Object locking = configProps.getOrDefault( MAVEN_RESOLVER_LOCKING_KEY, MAVEN_RESOLVER_LOCKING_DEFAULT );
+        if ( MAVEN_RESOLVER_LOCKING_DEFAULT.equals( locking ) || MAVEN_RESOLVER_LOCKING_FILE.equals( locking ) )
+        {
+            // The "default" mode (user did not set anything) is same as "file" mode
+            configProps.put( MAVEN_RESOLVER_LOCKING_LOCK_FACTORY_KEY, "file-lock" );
+            configProps.put( MAVEN_RESOLVER_LOCKING_NAME_MAPPER_KEY, "file-gav" );
+        }
+        else if ( MAVEN_RESOLVER_LOCKING_LOCAL.equals( locking ) )
+        {
+            configProps.put( MAVEN_RESOLVER_LOCKING_LOCK_FACTORY_KEY, "rwlock-local" );
+            configProps.put( MAVEN_RESOLVER_LOCKING_NAME_MAPPER_KEY, "gav" );
+        }
+        else if ( !MAVEN_RESOLVER_LOCKING_AUTO.equals( locking ) )
+        {
+            throw new IllegalArgumentException( "Unknown resolver locking mode '" + transport
+                    + "'. Supported locking modes are: " + MAVEN_RESOLVER_LOCKING_FILE + ", "
+                    + MAVEN_RESOLVER_LOCKING_LOCAL + ", " + MAVEN_RESOLVER_LOCKING_AUTO );
+        }
+
         session.setTransferListener( request.getTransferListener() );
 
         session.setRepositoryListener( eventSpyDispatcher.chainListener( new LoggingRepositoryListener( logger ) ) );