You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sj...@apache.org on 2022/12/01 21:59:54 UTC

[maven] branch MNG-7612-3.9 created (now 3bda1cff3)

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

sjaranowski pushed a change to branch MNG-7612-3.9
in repository https://gitbox.apache.org/repos/asf/maven.git


      at 3bda1cff3 [MNG-7612] Chained LRM

This branch includes the following new commits:

     new 3bda1cff3 [MNG-7612] Chained LRM

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[maven] 01/01: [MNG-7612] Chained LRM

Posted by sj...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sjaranowski pushed a commit to branch MNG-7612-3.9
in repository https://gitbox.apache.org/repos/asf/maven.git

commit 3bda1cff385e31795601a43086773cfd0f1a332a
Author: Tamas Cservenak <ta...@cservenak.net>
AuthorDate: Thu Dec 1 19:53:00 2022 +0100

    [MNG-7612] Chained LRM
    
    Adds new feature: Chained Local Repository Manager.
    
    ---
    
    https://issues.apache.org/jira/browse/MNG-7612
---
 .../DefaultRepositorySystemSessionFactory.java     | 49 +++++++++++++++++++++-
 1 file changed, 48 insertions(+), 1 deletion(-)

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 681d641ad..42007e252 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
@@ -41,12 +41,15 @@ import org.eclipse.aether.ConfigurationProperties;
 import org.eclipse.aether.DefaultRepositorySystemSession;
 import org.eclipse.aether.RepositorySystem;
 import org.eclipse.aether.repository.LocalRepository;
+import org.eclipse.aether.repository.LocalRepositoryManager;
 import org.eclipse.aether.repository.NoLocalRepositoryManagerException;
 import org.eclipse.aether.repository.RepositoryPolicy;
 import org.eclipse.aether.repository.WorkspaceReader;
 import org.eclipse.aether.resolution.ResolutionErrorPolicy;
 import org.eclipse.aether.spi.localrepo.LocalRepositoryManagerFactory;
+import org.eclipse.aether.util.ConfigUtils;
 import org.eclipse.aether.util.repository.AuthenticationBuilder;
+import org.eclipse.aether.util.repository.ChainedLocalRepositoryManager;
 import org.eclipse.aether.util.repository.DefaultAuthenticationSelector;
 import org.eclipse.aether.util.repository.DefaultMirrorSelector;
 import org.eclipse.aether.util.repository.DefaultProxySelector;
@@ -56,17 +59,38 @@ import org.eclipse.sisu.Nullable;
 import javax.inject.Inject;
 import javax.inject.Named;
 
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
 
+import static java.util.stream.Collectors.toList;
+
 /**
  * @since 3.3.0
  */
 @Named
 public class DefaultRepositorySystemSessionFactory
 {
+    /**
+     * User property for chained LRM: list of "tail" local repository paths (separated by comma), to be used with
+     * {@link ChainedLocalRepositoryManager}.
+     * Default value: {@code null}, no chained LRM is used.
+     *
+     * @since 3.9.0
+     */
+    private static final String MAVEN_REPO_LOCAL_TAIL = "maven.repo.local.tail";
+
+    /**
+     * User property for chained LRM: should artifact availability be ignored in tail local repositories or not.
+     * Default: {@code true}, will ignore availability from tail local repositories.
+
+     * @since 3.9.0
+     */
+    private static final String MAVEN_REPO_LOCAL_TAIL_IGNORE_AVAILABILITY = "maven.repo.local.tail.ignoreAvailability";
+
     private static final String MAVEN_RESOLVER_TRANSPORT_KEY = "maven.resolver.transport";
 
     private static final String MAVEN_RESOLVER_TRANSPORT_DEFAULT = "default";
@@ -308,7 +332,30 @@ public class DefaultRepositorySystemSessionFactory
         }
         else
         {
-            session.setLocalRepositoryManager( repoSystem.newLocalRepositoryManager( session, localRepo ) );
+            LocalRepositoryManager lrm = repoSystem.newLocalRepositoryManager( session, localRepo );
+
+            String localRepoTail = ConfigUtils.getString( session,
+                    null, MAVEN_REPO_LOCAL_TAIL );
+            if ( localRepoTail != null )
+            {
+                boolean ignoreTailAvailability = ConfigUtils.getBoolean( session,
+                        true, MAVEN_REPO_LOCAL_TAIL_IGNORE_AVAILABILITY );
+                List<LocalRepositoryManager> tail = new ArrayList<>();
+                List<String> paths = Arrays.stream( localRepoTail.split( "," ) )
+                        .filter( p -> p != null && !p.trim().isEmpty() )
+                        .collect( toList() );
+                for ( String path : paths )
+                {
+                    tail.add( repoSystem.newLocalRepositoryManager( session, new LocalRepository( path ) ) );
+                }
+                session.setLocalRepositoryManager(
+                        new ChainedLocalRepositoryManager( lrm, tail, ignoreTailAvailability )
+                );
+            }
+            else
+            {
+                session.setLocalRepositoryManager( lrm );
+            }
         }
     }