|
18 | 18 | */ |
19 | 19 | package org.apache.maven.internal.aether; |
20 | 20 |
|
| 21 | +import static java.util.stream.Collectors.toList; |
| 22 | + |
| 23 | +import java.util.ArrayList; |
| 24 | +import java.util.Arrays; |
21 | 25 | import java.util.HashMap; |
22 | 26 | import java.util.LinkedHashMap; |
23 | 27 | import java.util.List; |
|
48 | 52 | import org.eclipse.aether.DefaultRepositorySystemSession; |
49 | 53 | import org.eclipse.aether.RepositorySystem; |
50 | 54 | import org.eclipse.aether.repository.LocalRepository; |
| 55 | +import org.eclipse.aether.repository.LocalRepositoryManager; |
51 | 56 | import org.eclipse.aether.repository.NoLocalRepositoryManagerException; |
52 | 57 | import org.eclipse.aether.repository.RepositoryPolicy; |
53 | 58 | import org.eclipse.aether.repository.WorkspaceReader; |
54 | 59 | import org.eclipse.aether.resolution.ResolutionErrorPolicy; |
55 | 60 | import org.eclipse.aether.spi.localrepo.LocalRepositoryManagerFactory; |
| 61 | +import org.eclipse.aether.util.ConfigUtils; |
56 | 62 | import org.eclipse.aether.util.repository.AuthenticationBuilder; |
| 63 | +import org.eclipse.aether.util.repository.ChainedLocalRepositoryManager; |
57 | 64 | import org.eclipse.aether.util.repository.DefaultAuthenticationSelector; |
58 | 65 | import org.eclipse.aether.util.repository.DefaultMirrorSelector; |
59 | 66 | import org.eclipse.aether.util.repository.DefaultProxySelector; |
|
65 | 72 | */ |
66 | 73 | @Named |
67 | 74 | public class DefaultRepositorySystemSessionFactory { |
| 75 | + /** |
| 76 | + * User property for chained LRM: list of "tail" local repository paths (separated by comma), to be used with |
| 77 | + * {@link ChainedLocalRepositoryManager}. |
| 78 | + * Default value: {@code null}, no chained LRM is used. |
| 79 | + * |
| 80 | + * @since 3.9.0 |
| 81 | + */ |
| 82 | + private static final String MAVEN_REPO_LOCAL_TAIL = "maven.repo.local.tail"; |
| 83 | + |
| 84 | + /** |
| 85 | + * User property for chained LRM: should artifact availability be ignored in tail local repositories or not. |
| 86 | + * Default: {@code true}, will ignore availability from tail local repositories. |
| 87 | + * |
| 88 | + * @since 3.9.0 |
| 89 | + */ |
| 90 | + private static final String MAVEN_REPO_LOCAL_TAIL_IGNORE_AVAILABILITY = "maven.repo.local.tail.ignoreAvailability"; |
| 91 | + |
68 | 92 | private static final String MAVEN_RESOLVER_TRANSPORT_KEY = "maven.resolver.transport"; |
69 | 93 |
|
70 | 94 | private static final String MAVEN_RESOLVER_TRANSPORT_DEFAULT = "default"; |
@@ -354,7 +378,23 @@ private void setUpLocalRepositoryManager(MavenExecutionRequest request, DefaultR |
354 | 378 | session.setLocalRepositoryManager(repoSystem.newLocalRepositoryManager(session, localRepo)); |
355 | 379 | } |
356 | 380 | } else { |
357 | | - session.setLocalRepositoryManager(repoSystem.newLocalRepositoryManager(session, localRepo)); |
| 381 | + LocalRepositoryManager lrm = repoSystem.newLocalRepositoryManager(session, localRepo); |
| 382 | + |
| 383 | + String localRepoTail = ConfigUtils.getString(session, null, MAVEN_REPO_LOCAL_TAIL); |
| 384 | + if (localRepoTail != null) { |
| 385 | + boolean ignoreTailAvailability = |
| 386 | + ConfigUtils.getBoolean(session, true, MAVEN_REPO_LOCAL_TAIL_IGNORE_AVAILABILITY); |
| 387 | + List<LocalRepositoryManager> tail = new ArrayList<>(); |
| 388 | + List<String> paths = Arrays.stream(localRepoTail.split(",")) |
| 389 | + .filter(p -> p != null && !p.trim().isEmpty()) |
| 390 | + .collect(toList()); |
| 391 | + for (String path : paths) { |
| 392 | + tail.add(repoSystem.newLocalRepositoryManager(session, new LocalRepository(path))); |
| 393 | + } |
| 394 | + session.setLocalRepositoryManager(new ChainedLocalRepositoryManager(lrm, tail, ignoreTailAvailability)); |
| 395 | + } else { |
| 396 | + session.setLocalRepositoryManager(lrm); |
| 397 | + } |
358 | 398 | } |
359 | 399 | } |
360 | 400 |
|
|
0 commit comments