1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.repository.internal;
20
21 import java.util.HashMap;
22 import java.util.LinkedHashMap;
23 import java.util.List;
24 import java.util.Map;
25 import java.util.concurrent.atomic.AtomicBoolean;
26 import java.util.function.Supplier;
27
28 import org.apache.maven.api.services.ModelBuilder;
29 import org.apache.maven.internal.impl.DefaultModelUrlNormalizer;
30 import org.apache.maven.internal.impl.DefaultModelVersionParser;
31 import org.apache.maven.internal.impl.DefaultModelXmlFactory;
32 import org.apache.maven.internal.impl.DefaultPluginConfigurationExpander;
33 import org.apache.maven.internal.impl.DefaultSuperPomProvider;
34 import org.apache.maven.internal.impl.DefaultUrlNormalizer;
35 import org.apache.maven.internal.impl.model.DefaultDependencyManagementImporter;
36 import org.apache.maven.internal.impl.model.DefaultDependencyManagementInjector;
37 import org.apache.maven.internal.impl.model.DefaultInheritanceAssembler;
38 import org.apache.maven.internal.impl.model.DefaultInterpolator;
39 import org.apache.maven.internal.impl.model.DefaultModelBuilder;
40 import org.apache.maven.internal.impl.model.DefaultModelCacheFactory;
41 import org.apache.maven.internal.impl.model.DefaultModelInterpolator;
42 import org.apache.maven.internal.impl.model.DefaultModelNormalizer;
43 import org.apache.maven.internal.impl.model.DefaultModelPathTranslator;
44 import org.apache.maven.internal.impl.model.DefaultModelProcessor;
45 import org.apache.maven.internal.impl.model.DefaultModelValidator;
46 import org.apache.maven.internal.impl.model.DefaultPathTranslator;
47 import org.apache.maven.internal.impl.model.DefaultPluginManagementInjector;
48 import org.apache.maven.internal.impl.model.DefaultProfileInjector;
49 import org.apache.maven.internal.impl.model.DefaultProfileSelector;
50 import org.apache.maven.internal.impl.model.ProfileActivationFilePathInterpolator;
51 import org.apache.maven.internal.impl.model.rootlocator.DefaultRootLocator;
52 import org.apache.maven.internal.impl.resolver.DefaultArtifactDescriptorReader;
53 import org.apache.maven.internal.impl.resolver.DefaultVersionRangeResolver;
54 import org.apache.maven.internal.impl.resolver.DefaultVersionResolver;
55 import org.apache.maven.internal.impl.resolver.MavenArtifactRelocationSource;
56 import org.apache.maven.internal.impl.resolver.PluginsMetadataGeneratorFactory;
57 import org.apache.maven.internal.impl.resolver.SnapshotMetadataGeneratorFactory;
58 import org.apache.maven.internal.impl.resolver.VersionsMetadataGeneratorFactory;
59 import org.apache.maven.internal.impl.resolver.relocation.DistributionManagementArtifactRelocationSource;
60 import org.apache.maven.internal.impl.resolver.relocation.UserPropertiesArtifactRelocationSource;
61 import org.eclipse.aether.RepositoryListener;
62 import org.eclipse.aether.RepositorySystem;
63 import org.eclipse.aether.connector.basic.BasicRepositoryConnectorFactory;
64 import org.eclipse.aether.impl.ArtifactDescriptorReader;
65 import org.eclipse.aether.impl.ArtifactResolver;
66 import org.eclipse.aether.impl.DependencyCollector;
67 import org.eclipse.aether.impl.Deployer;
68 import org.eclipse.aether.impl.Installer;
69 import org.eclipse.aether.impl.LocalRepositoryProvider;
70 import org.eclipse.aether.impl.MetadataGeneratorFactory;
71 import org.eclipse.aether.impl.MetadataResolver;
72 import org.eclipse.aether.impl.OfflineController;
73 import org.eclipse.aether.impl.RemoteRepositoryFilterManager;
74 import org.eclipse.aether.impl.RemoteRepositoryManager;
75 import org.eclipse.aether.impl.RepositoryConnectorProvider;
76 import org.eclipse.aether.impl.RepositoryEventDispatcher;
77 import org.eclipse.aether.impl.RepositorySystemLifecycle;
78 import org.eclipse.aether.impl.UpdateCheckManager;
79 import org.eclipse.aether.impl.UpdatePolicyAnalyzer;
80 import org.eclipse.aether.impl.VersionRangeResolver;
81 import org.eclipse.aether.impl.VersionResolver;
82 import org.eclipse.aether.internal.impl.DefaultArtifactPredicateFactory;
83 import org.eclipse.aether.internal.impl.DefaultArtifactResolver;
84 import org.eclipse.aether.internal.impl.DefaultChecksumPolicyProvider;
85 import org.eclipse.aether.internal.impl.DefaultChecksumProcessor;
86 import org.eclipse.aether.internal.impl.DefaultDeployer;
87 import org.eclipse.aether.internal.impl.DefaultInstaller;
88 import org.eclipse.aether.internal.impl.DefaultLocalPathComposer;
89 import org.eclipse.aether.internal.impl.DefaultLocalPathPrefixComposerFactory;
90 import org.eclipse.aether.internal.impl.DefaultLocalRepositoryProvider;
91 import org.eclipse.aether.internal.impl.DefaultMetadataResolver;
92 import org.eclipse.aether.internal.impl.DefaultOfflineController;
93 import org.eclipse.aether.internal.impl.DefaultPathProcessor;
94 import org.eclipse.aether.internal.impl.DefaultRemoteRepositoryManager;
95 import org.eclipse.aether.internal.impl.DefaultRepositoryConnectorProvider;
96 import org.eclipse.aether.internal.impl.DefaultRepositoryEventDispatcher;
97 import org.eclipse.aether.internal.impl.DefaultRepositoryLayoutProvider;
98 import org.eclipse.aether.internal.impl.DefaultRepositorySystem;
99 import org.eclipse.aether.internal.impl.DefaultRepositorySystemLifecycle;
100 import org.eclipse.aether.internal.impl.DefaultTrackingFileManager;
101 import org.eclipse.aether.internal.impl.DefaultTransporterProvider;
102 import org.eclipse.aether.internal.impl.DefaultUpdateCheckManager;
103 import org.eclipse.aether.internal.impl.DefaultUpdatePolicyAnalyzer;
104 import org.eclipse.aether.internal.impl.EnhancedLocalRepositoryManagerFactory;
105 import org.eclipse.aether.internal.impl.LocalPathComposer;
106 import org.eclipse.aether.internal.impl.LocalPathPrefixComposerFactory;
107 import org.eclipse.aether.internal.impl.Maven2RepositoryLayoutFactory;
108 import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory;
109 import org.eclipse.aether.internal.impl.TrackingFileManager;
110 import org.eclipse.aether.internal.impl.checksum.DefaultChecksumAlgorithmFactorySelector;
111 import org.eclipse.aether.internal.impl.checksum.Md5ChecksumAlgorithmFactory;
112 import org.eclipse.aether.internal.impl.checksum.Sha1ChecksumAlgorithmFactory;
113 import org.eclipse.aether.internal.impl.checksum.Sha256ChecksumAlgorithmFactory;
114 import org.eclipse.aether.internal.impl.checksum.Sha512ChecksumAlgorithmFactory;
115 import org.eclipse.aether.internal.impl.checksum.SparseDirectoryTrustedChecksumsSource;
116 import org.eclipse.aether.internal.impl.checksum.SummaryFileTrustedChecksumsSource;
117 import org.eclipse.aether.internal.impl.checksum.TrustedToProvidedChecksumsSourceAdapter;
118 import org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector;
119 import org.eclipse.aether.internal.impl.collect.DependencyCollectorDelegate;
120 import org.eclipse.aether.internal.impl.collect.bf.BfDependencyCollector;
121 import org.eclipse.aether.internal.impl.collect.df.DfDependencyCollector;
122 import org.eclipse.aether.internal.impl.filter.DefaultRemoteRepositoryFilterManager;
123 import org.eclipse.aether.internal.impl.filter.GroupIdRemoteRepositoryFilterSource;
124 import org.eclipse.aether.internal.impl.filter.PrefixesRemoteRepositoryFilterSource;
125 import org.eclipse.aether.internal.impl.resolution.TrustedChecksumsArtifactResolverPostProcessor;
126 import org.eclipse.aether.internal.impl.synccontext.DefaultSyncContextFactory;
127 import org.eclipse.aether.internal.impl.synccontext.named.NameMapper;
128 import org.eclipse.aether.internal.impl.synccontext.named.NameMappers;
129 import org.eclipse.aether.internal.impl.synccontext.named.NamedLockFactoryAdapterFactory;
130 import org.eclipse.aether.internal.impl.synccontext.named.NamedLockFactoryAdapterFactoryImpl;
131 import org.eclipse.aether.internal.impl.transport.http.DefaultChecksumExtractor;
132 import org.eclipse.aether.internal.impl.transport.http.Nx2ChecksumExtractor;
133 import org.eclipse.aether.internal.impl.transport.http.XChecksumExtractor;
134 import org.eclipse.aether.named.NamedLockFactory;
135 import org.eclipse.aether.named.providers.FileLockNamedLockFactory;
136 import org.eclipse.aether.named.providers.LocalReadWriteLockNamedLockFactory;
137 import org.eclipse.aether.named.providers.LocalSemaphoreNamedLockFactory;
138 import org.eclipse.aether.named.providers.NoopNamedLockFactory;
139 import org.eclipse.aether.spi.artifact.ArtifactPredicateFactory;
140 import org.eclipse.aether.spi.artifact.decorator.ArtifactDecoratorFactory;
141 import org.eclipse.aether.spi.artifact.generator.ArtifactGeneratorFactory;
142 import org.eclipse.aether.spi.checksums.ProvidedChecksumsSource;
143 import org.eclipse.aether.spi.checksums.TrustedChecksumsSource;
144 import org.eclipse.aether.spi.connector.RepositoryConnectorFactory;
145 import org.eclipse.aether.spi.connector.checksum.ChecksumAlgorithmFactory;
146 import org.eclipse.aether.spi.connector.checksum.ChecksumAlgorithmFactorySelector;
147 import org.eclipse.aether.spi.connector.checksum.ChecksumPolicyProvider;
148 import org.eclipse.aether.spi.connector.filter.RemoteRepositoryFilterSource;
149 import org.eclipse.aether.spi.connector.layout.RepositoryLayoutFactory;
150 import org.eclipse.aether.spi.connector.layout.RepositoryLayoutProvider;
151 import org.eclipse.aether.spi.connector.transport.TransporterFactory;
152 import org.eclipse.aether.spi.connector.transport.TransporterProvider;
153 import org.eclipse.aether.spi.connector.transport.http.ChecksumExtractor;
154 import org.eclipse.aether.spi.connector.transport.http.ChecksumExtractorStrategy;
155 import org.eclipse.aether.spi.io.ChecksumProcessor;
156 import org.eclipse.aether.spi.io.PathProcessor;
157 import org.eclipse.aether.spi.localrepo.LocalRepositoryManagerFactory;
158 import org.eclipse.aether.spi.resolution.ArtifactResolverPostProcessor;
159 import org.eclipse.aether.spi.synccontext.SyncContextFactory;
160 import org.eclipse.aether.transport.apache.ApacheTransporterFactory;
161 import org.eclipse.aether.transport.file.FileTransporterFactory;
162 import org.eclipse.aether.util.version.GenericVersionScheme;
163 import org.eclipse.aether.version.VersionScheme;
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189 @Deprecated(since = "4.0.0")
190 public class MavenRepositorySystemSupplier implements Supplier<RepositorySystem> {
191 private final AtomicBoolean closed = new AtomicBoolean(false);
192
193 public MavenRepositorySystemSupplier() {}
194
195 private void checkClosed() {
196 if (closed.get()) {
197 throw new IllegalStateException("Supplier is closed");
198 }
199 }
200
201 private PathProcessor pathProcessor;
202
203 public final PathProcessor getPathProcessor() {
204 checkClosed();
205 if (pathProcessor == null) {
206 pathProcessor = createPathProcessor();
207 }
208 return pathProcessor;
209 }
210
211 protected PathProcessor createPathProcessor() {
212 return new DefaultPathProcessor();
213 }
214
215 private ChecksumProcessor checksumProcessor;
216
217 public final ChecksumProcessor getChecksumProcessor() {
218 checkClosed();
219 if (checksumProcessor == null) {
220 checksumProcessor = createChecksumProcessor();
221 }
222 return checksumProcessor;
223 }
224
225 protected ChecksumProcessor createChecksumProcessor() {
226 return new DefaultChecksumProcessor(getPathProcessor());
227 }
228
229 private TrackingFileManager trackingFileManager;
230
231 public final TrackingFileManager getTrackingFileManager() {
232 checkClosed();
233 if (trackingFileManager == null) {
234 trackingFileManager = createTrackingFileManager();
235 }
236 return trackingFileManager;
237 }
238
239 protected TrackingFileManager createTrackingFileManager() {
240 return new DefaultTrackingFileManager();
241 }
242
243 private LocalPathComposer localPathComposer;
244
245 public final LocalPathComposer getLocalPathComposer() {
246 checkClosed();
247 if (localPathComposer == null) {
248 localPathComposer = createLocalPathComposer();
249 }
250 return localPathComposer;
251 }
252
253 protected LocalPathComposer createLocalPathComposer() {
254 return new DefaultLocalPathComposer();
255 }
256
257 private LocalPathPrefixComposerFactory localPathPrefixComposerFactory;
258
259 public final LocalPathPrefixComposerFactory getLocalPathPrefixComposerFactory() {
260 checkClosed();
261 if (localPathPrefixComposerFactory == null) {
262 localPathPrefixComposerFactory = createLocalPathPrefixComposerFactory();
263 }
264 return localPathPrefixComposerFactory;
265 }
266
267 protected LocalPathPrefixComposerFactory createLocalPathPrefixComposerFactory() {
268 return new DefaultLocalPathPrefixComposerFactory();
269 }
270
271 private RepositorySystemLifecycle repositorySystemLifecycle;
272
273 public final RepositorySystemLifecycle getRepositorySystemLifecycle() {
274 checkClosed();
275 if (repositorySystemLifecycle == null) {
276 repositorySystemLifecycle = createRepositorySystemLifecycle();
277 repositorySystemLifecycle.addOnSystemEndedHandler(() -> closed.set(true));
278 }
279 return repositorySystemLifecycle;
280 }
281
282 protected RepositorySystemLifecycle createRepositorySystemLifecycle() {
283 return new DefaultRepositorySystemLifecycle();
284 }
285
286 private OfflineController offlineController;
287
288 public final OfflineController getOfflineController() {
289 checkClosed();
290 if (offlineController == null) {
291 offlineController = createOfflineController();
292 }
293 return offlineController;
294 }
295
296 protected OfflineController createOfflineController() {
297 return new DefaultOfflineController();
298 }
299
300 private UpdatePolicyAnalyzer updatePolicyAnalyzer;
301
302 public final UpdatePolicyAnalyzer getUpdatePolicyAnalyzer() {
303 checkClosed();
304 if (updatePolicyAnalyzer == null) {
305 updatePolicyAnalyzer = createUpdatePolicyAnalyzer();
306 }
307 return updatePolicyAnalyzer;
308 }
309
310 protected UpdatePolicyAnalyzer createUpdatePolicyAnalyzer() {
311 return new DefaultUpdatePolicyAnalyzer();
312 }
313
314 private ChecksumPolicyProvider checksumPolicyProvider;
315
316 public final ChecksumPolicyProvider getChecksumPolicyProvider() {
317 checkClosed();
318 if (checksumPolicyProvider == null) {
319 checksumPolicyProvider = createChecksumPolicyProvider();
320 }
321 return checksumPolicyProvider;
322 }
323
324 protected ChecksumPolicyProvider createChecksumPolicyProvider() {
325 return new DefaultChecksumPolicyProvider();
326 }
327
328 private UpdateCheckManager updateCheckManager;
329
330 public final UpdateCheckManager getUpdateCheckManager() {
331 checkClosed();
332 if (updateCheckManager == null) {
333 updateCheckManager = createUpdateCheckManager();
334 }
335 return updateCheckManager;
336 }
337
338 protected UpdateCheckManager createUpdateCheckManager() {
339 return new DefaultUpdateCheckManager(getTrackingFileManager(), getUpdatePolicyAnalyzer(), getPathProcessor());
340 }
341
342 private Map<String, NamedLockFactory> namedLockFactories;
343
344 public final Map<String, NamedLockFactory> getNamedLockFactories() {
345 checkClosed();
346 if (namedLockFactories == null) {
347 namedLockFactories = createNamedLockFactories();
348 }
349 return namedLockFactories;
350 }
351
352 protected Map<String, NamedLockFactory> createNamedLockFactories() {
353 HashMap<String, NamedLockFactory> result = new HashMap<>();
354 result.put(NoopNamedLockFactory.NAME, new NoopNamedLockFactory());
355 result.put(LocalReadWriteLockNamedLockFactory.NAME, new LocalReadWriteLockNamedLockFactory());
356 result.put(LocalSemaphoreNamedLockFactory.NAME, new LocalSemaphoreNamedLockFactory());
357 result.put(FileLockNamedLockFactory.NAME, new FileLockNamedLockFactory());
358 return result;
359 }
360
361 private Map<String, NameMapper> nameMappers;
362
363 public final Map<String, NameMapper> getNameMappers() {
364 checkClosed();
365 if (nameMappers == null) {
366 nameMappers = createNameMappers();
367 }
368 return nameMappers;
369 }
370
371 protected Map<String, NameMapper> createNameMappers() {
372 HashMap<String, NameMapper> result = new HashMap<>();
373 result.put(NameMappers.STATIC_NAME, NameMappers.staticNameMapper());
374 result.put(NameMappers.GAV_NAME, NameMappers.gavNameMapper());
375 result.put(NameMappers.DISCRIMINATING_NAME, NameMappers.discriminatingNameMapper());
376 result.put(NameMappers.FILE_GAV_NAME, NameMappers.fileGavNameMapper());
377 result.put(NameMappers.FILE_HGAV_NAME, NameMappers.fileHashingGavNameMapper());
378 return result;
379 }
380
381 private NamedLockFactoryAdapterFactory namedLockFactoryAdapterFactory;
382
383 public final NamedLockFactoryAdapterFactory getNamedLockFactoryAdapterFactory() {
384 checkClosed();
385 if (namedLockFactoryAdapterFactory == null) {
386 namedLockFactoryAdapterFactory = createNamedLockFactoryAdapterFactory();
387 }
388 return namedLockFactoryAdapterFactory;
389 }
390
391 protected NamedLockFactoryAdapterFactory createNamedLockFactoryAdapterFactory() {
392 return new NamedLockFactoryAdapterFactoryImpl(
393 getNamedLockFactories(), getNameMappers(), getRepositorySystemLifecycle());
394 }
395
396 private SyncContextFactory syncContextFactory;
397
398 public final SyncContextFactory getSyncContextFactory() {
399 checkClosed();
400 if (syncContextFactory == null) {
401 syncContextFactory = createSyncContextFactory();
402 }
403 return syncContextFactory;
404 }
405
406 protected SyncContextFactory createSyncContextFactory() {
407 return new DefaultSyncContextFactory(getNamedLockFactoryAdapterFactory());
408 }
409
410 private Map<String, ChecksumAlgorithmFactory> checksumAlgorithmFactories;
411
412 public final Map<String, ChecksumAlgorithmFactory> getChecksumAlgorithmFactories() {
413 checkClosed();
414 if (checksumAlgorithmFactories == null) {
415 checksumAlgorithmFactories = createChecksumAlgorithmFactories();
416 }
417 return checksumAlgorithmFactories;
418 }
419
420 protected Map<String, ChecksumAlgorithmFactory> createChecksumAlgorithmFactories() {
421 HashMap<String, ChecksumAlgorithmFactory> result = new HashMap<>();
422 result.put(Sha512ChecksumAlgorithmFactory.NAME, new Sha512ChecksumAlgorithmFactory());
423 result.put(Sha256ChecksumAlgorithmFactory.NAME, new Sha256ChecksumAlgorithmFactory());
424 result.put(Sha1ChecksumAlgorithmFactory.NAME, new Sha1ChecksumAlgorithmFactory());
425 result.put(Md5ChecksumAlgorithmFactory.NAME, new Md5ChecksumAlgorithmFactory());
426 return result;
427 }
428
429 private ChecksumAlgorithmFactorySelector checksumAlgorithmFactorySelector;
430
431 public final ChecksumAlgorithmFactorySelector getChecksumAlgorithmFactorySelector() {
432 checkClosed();
433 if (checksumAlgorithmFactorySelector == null) {
434 checksumAlgorithmFactorySelector = createChecksumAlgorithmFactorySelector();
435 }
436 return checksumAlgorithmFactorySelector;
437 }
438
439 protected ChecksumAlgorithmFactorySelector createChecksumAlgorithmFactorySelector() {
440 return new DefaultChecksumAlgorithmFactorySelector(getChecksumAlgorithmFactories());
441 }
442
443 private ArtifactPredicateFactory artifactPredicateFactory;
444
445 public final ArtifactPredicateFactory getArtifactPredicateFactory() {
446 checkClosed();
447 if (artifactPredicateFactory == null) {
448 artifactPredicateFactory = createArtifactPredicateFactory();
449 }
450 return artifactPredicateFactory;
451 }
452
453 protected ArtifactPredicateFactory createArtifactPredicateFactory() {
454 return new DefaultArtifactPredicateFactory(getChecksumAlgorithmFactorySelector());
455 }
456
457 private Map<String, RepositoryLayoutFactory> repositoryLayoutFactories;
458
459 public final Map<String, RepositoryLayoutFactory> getRepositoryLayoutFactories() {
460 checkClosed();
461 if (repositoryLayoutFactories == null) {
462 repositoryLayoutFactories = createRepositoryLayoutFactories();
463 }
464 return repositoryLayoutFactories;
465 }
466
467 protected Map<String, RepositoryLayoutFactory> createRepositoryLayoutFactories() {
468 HashMap<String, RepositoryLayoutFactory> result = new HashMap<>();
469 result.put(
470 Maven2RepositoryLayoutFactory.NAME,
471 new Maven2RepositoryLayoutFactory(
472 getChecksumAlgorithmFactorySelector(), getArtifactPredicateFactory()));
473 return result;
474 }
475
476 private RepositoryLayoutProvider repositoryLayoutProvider;
477
478 public final RepositoryLayoutProvider getRepositoryLayoutProvider() {
479 checkClosed();
480 if (repositoryLayoutProvider == null) {
481 repositoryLayoutProvider = createRepositoryLayoutProvider();
482 }
483 return repositoryLayoutProvider;
484 }
485
486 protected RepositoryLayoutProvider createRepositoryLayoutProvider() {
487 return new DefaultRepositoryLayoutProvider(getRepositoryLayoutFactories());
488 }
489
490 private LocalRepositoryProvider localRepositoryProvider;
491
492 public final LocalRepositoryProvider getLocalRepositoryProvider() {
493 checkClosed();
494 if (localRepositoryProvider == null) {
495 localRepositoryProvider = createLocalRepositoryProvider();
496 }
497 return localRepositoryProvider;
498 }
499
500 protected LocalRepositoryProvider createLocalRepositoryProvider() {
501 LocalPathComposer localPathComposer = getLocalPathComposer();
502 HashMap<String, LocalRepositoryManagerFactory> localRepositoryProviders = new HashMap<>(2);
503 localRepositoryProviders.put(
504 SimpleLocalRepositoryManagerFactory.NAME, new SimpleLocalRepositoryManagerFactory(localPathComposer));
505 localRepositoryProviders.put(
506 EnhancedLocalRepositoryManagerFactory.NAME,
507 new EnhancedLocalRepositoryManagerFactory(
508 localPathComposer, getTrackingFileManager(), getLocalPathPrefixComposerFactory()));
509 return new DefaultLocalRepositoryProvider(localRepositoryProviders);
510 }
511
512 private RemoteRepositoryManager remoteRepositoryManager;
513
514 public final RemoteRepositoryManager getRemoteRepositoryManager() {
515 checkClosed();
516 if (remoteRepositoryManager == null) {
517 remoteRepositoryManager = createRemoteRepositoryManager();
518 }
519 return remoteRepositoryManager;
520 }
521
522 protected RemoteRepositoryManager createRemoteRepositoryManager() {
523 return new DefaultRemoteRepositoryManager(getUpdatePolicyAnalyzer(), getChecksumPolicyProvider());
524 }
525
526 private Map<String, RemoteRepositoryFilterSource> remoteRepositoryFilterSources;
527
528 public final Map<String, RemoteRepositoryFilterSource> getRemoteRepositoryFilterSources() {
529 checkClosed();
530 if (remoteRepositoryFilterSources == null) {
531 remoteRepositoryFilterSources = createRemoteRepositoryFilterSources();
532 }
533 return remoteRepositoryFilterSources;
534 }
535
536 protected Map<String, RemoteRepositoryFilterSource> createRemoteRepositoryFilterSources() {
537 HashMap<String, RemoteRepositoryFilterSource> result = new HashMap<>();
538 result.put(
539 GroupIdRemoteRepositoryFilterSource.NAME,
540 new GroupIdRemoteRepositoryFilterSource(getRepositorySystemLifecycle()));
541 result.put(
542 PrefixesRemoteRepositoryFilterSource.NAME,
543 new PrefixesRemoteRepositoryFilterSource(getRepositoryLayoutProvider()));
544 return result;
545 }
546
547 private RemoteRepositoryFilterManager remoteRepositoryFilterManager;
548
549 public final RemoteRepositoryFilterManager getRemoteRepositoryFilterManager() {
550 checkClosed();
551 if (remoteRepositoryFilterManager == null) {
552 remoteRepositoryFilterManager = createRemoteRepositoryFilterManager();
553 }
554 return remoteRepositoryFilterManager;
555 }
556
557 protected RemoteRepositoryFilterManager createRemoteRepositoryFilterManager() {
558 return new DefaultRemoteRepositoryFilterManager(getRemoteRepositoryFilterSources());
559 }
560
561 private Map<String, RepositoryListener> repositoryListeners;
562
563 public final Map<String, RepositoryListener> getRepositoryListeners() {
564 checkClosed();
565 if (repositoryListeners == null) {
566 repositoryListeners = createRepositoryListeners();
567 }
568 return repositoryListeners;
569 }
570
571 protected Map<String, RepositoryListener> createRepositoryListeners() {
572 return new HashMap<>();
573 }
574
575 private RepositoryEventDispatcher repositoryEventDispatcher;
576
577 public final RepositoryEventDispatcher getRepositoryEventDispatcher() {
578 checkClosed();
579 if (repositoryEventDispatcher == null) {
580 repositoryEventDispatcher = createRepositoryEventDispatcher();
581 }
582 return repositoryEventDispatcher;
583 }
584
585 protected RepositoryEventDispatcher createRepositoryEventDispatcher() {
586 return new DefaultRepositoryEventDispatcher(getRepositoryListeners());
587 }
588
589 private Map<String, TrustedChecksumsSource> trustedChecksumsSources;
590
591 public final Map<String, TrustedChecksumsSource> getTrustedChecksumsSources() {
592 checkClosed();
593 if (trustedChecksumsSources == null) {
594 trustedChecksumsSources = createTrustedChecksumsSources();
595 }
596 return trustedChecksumsSources;
597 }
598
599 protected Map<String, TrustedChecksumsSource> createTrustedChecksumsSources() {
600 HashMap<String, TrustedChecksumsSource> result = new HashMap<>();
601 result.put(
602 SparseDirectoryTrustedChecksumsSource.NAME,
603 new SparseDirectoryTrustedChecksumsSource(getChecksumProcessor(), getLocalPathComposer()));
604 result.put(
605 SummaryFileTrustedChecksumsSource.NAME,
606 new SummaryFileTrustedChecksumsSource(getLocalPathComposer(), getRepositorySystemLifecycle()));
607 return result;
608 }
609
610 private Map<String, ProvidedChecksumsSource> providedChecksumsSources;
611
612 public final Map<String, ProvidedChecksumsSource> getProvidedChecksumsSources() {
613 checkClosed();
614 if (providedChecksumsSources == null) {
615 providedChecksumsSources = createProvidedChecksumsSources();
616 }
617 return providedChecksumsSources;
618 }
619
620 protected Map<String, ProvidedChecksumsSource> createProvidedChecksumsSources() {
621 HashMap<String, ProvidedChecksumsSource> result = new HashMap<>();
622 result.put(
623 TrustedToProvidedChecksumsSourceAdapter.NAME,
624 new TrustedToProvidedChecksumsSourceAdapter(getTrustedChecksumsSources()));
625 return result;
626 }
627
628 private Map<String, ChecksumExtractorStrategy> checksumExtractorStrategies;
629
630 public final Map<String, ChecksumExtractorStrategy> getChecksumExtractorStrategies() {
631 checkClosed();
632 if (checksumExtractorStrategies == null) {
633 checksumExtractorStrategies = createChecksumExtractorStrategies();
634 }
635 return checksumExtractorStrategies;
636 }
637
638 protected Map<String, ChecksumExtractorStrategy> createChecksumExtractorStrategies() {
639 HashMap<String, ChecksumExtractorStrategy> result = new HashMap<>();
640 result.put(XChecksumExtractor.NAME, new XChecksumExtractor());
641 result.put(Nx2ChecksumExtractor.NAME, new Nx2ChecksumExtractor());
642 return result;
643 }
644
645 private ChecksumExtractor checksumExtractor;
646
647 public final ChecksumExtractor getChecksumExtractor() {
648 checkClosed();
649 if (checksumExtractor == null) {
650 checksumExtractor = createChecksumExtractor();
651 }
652 return checksumExtractor;
653 }
654
655 protected ChecksumExtractor createChecksumExtractor() {
656 return new DefaultChecksumExtractor(getChecksumExtractorStrategies());
657 }
658
659 private Map<String, TransporterFactory> transporterFactories;
660
661 public final Map<String, TransporterFactory> getTransporterFactories() {
662 checkClosed();
663 if (transporterFactories == null) {
664 transporterFactories = createTransporterFactories();
665 }
666 return transporterFactories;
667 }
668
669 protected Map<String, TransporterFactory> createTransporterFactories() {
670 HashMap<String, TransporterFactory> result = new HashMap<>();
671 result.put(FileTransporterFactory.NAME, new FileTransporterFactory());
672 result.put(
673 ApacheTransporterFactory.NAME,
674 new ApacheTransporterFactory(getChecksumExtractor(), getPathProcessor()));
675 return result;
676 }
677
678 private TransporterProvider transporterProvider;
679
680 public final TransporterProvider getTransporterProvider() {
681 checkClosed();
682 if (transporterProvider == null) {
683 transporterProvider = createTransporterProvider();
684 }
685 return transporterProvider;
686 }
687
688 protected TransporterProvider createTransporterProvider() {
689 return new DefaultTransporterProvider(getTransporterFactories());
690 }
691
692 private BasicRepositoryConnectorFactory basicRepositoryConnectorFactory;
693
694 public final BasicRepositoryConnectorFactory getBasicRepositoryConnectorFactory() {
695 checkClosed();
696 if (basicRepositoryConnectorFactory == null) {
697 basicRepositoryConnectorFactory = createBasicRepositoryConnectorFactory();
698 }
699 return basicRepositoryConnectorFactory;
700 }
701
702 protected BasicRepositoryConnectorFactory createBasicRepositoryConnectorFactory() {
703 return new BasicRepositoryConnectorFactory(
704 getTransporterProvider(),
705 getRepositoryLayoutProvider(),
706 getChecksumPolicyProvider(),
707 getChecksumProcessor(),
708 getProvidedChecksumsSources());
709 }
710
711 private Map<String, RepositoryConnectorFactory> repositoryConnectorFactories;
712
713 public final Map<String, RepositoryConnectorFactory> getRepositoryConnectorFactories() {
714 checkClosed();
715 if (repositoryConnectorFactories == null) {
716 repositoryConnectorFactories = createRepositoryConnectorFactories();
717 }
718 return repositoryConnectorFactories;
719 }
720
721 protected Map<String, RepositoryConnectorFactory> createRepositoryConnectorFactories() {
722 HashMap<String, RepositoryConnectorFactory> result = new HashMap<>();
723 result.put(BasicRepositoryConnectorFactory.NAME, getBasicRepositoryConnectorFactory());
724 return result;
725 }
726
727 private RepositoryConnectorProvider repositoryConnectorProvider;
728
729 public final RepositoryConnectorProvider getRepositoryConnectorProvider() {
730 checkClosed();
731 if (repositoryConnectorProvider == null) {
732 repositoryConnectorProvider = createRepositoryConnectorProvider();
733 }
734 return repositoryConnectorProvider;
735 }
736
737 protected RepositoryConnectorProvider createRepositoryConnectorProvider() {
738 return new DefaultRepositoryConnectorProvider(
739 getRepositoryConnectorFactories(), getRemoteRepositoryFilterManager());
740 }
741
742 private Installer installer;
743
744 public final Installer getInstaller() {
745 checkClosed();
746 if (installer == null) {
747 installer = createInstaller();
748 }
749 return installer;
750 }
751
752 protected Installer createInstaller() {
753 return new DefaultInstaller(
754 getPathProcessor(),
755 getRepositoryEventDispatcher(),
756 getArtifactGeneratorFactories(),
757 getMetadataGeneratorFactories(),
758 getSyncContextFactory());
759 }
760
761 private Deployer deployer;
762
763 public final Deployer getDeployer() {
764 checkClosed();
765 if (deployer == null) {
766 deployer = createDeployer();
767 }
768 return deployer;
769 }
770
771 protected Deployer createDeployer() {
772 return new DefaultDeployer(
773 getPathProcessor(),
774 getRepositoryEventDispatcher(),
775 getRepositoryConnectorProvider(),
776 getRemoteRepositoryManager(),
777 getUpdateCheckManager(),
778 getArtifactGeneratorFactories(),
779 getMetadataGeneratorFactories(),
780 getSyncContextFactory(),
781 getOfflineController());
782 }
783
784 private Map<String, DependencyCollectorDelegate> dependencyCollectorDelegates;
785
786 public final Map<String, DependencyCollectorDelegate> getDependencyCollectorDelegates() {
787 checkClosed();
788 if (dependencyCollectorDelegates == null) {
789 dependencyCollectorDelegates = createDependencyCollectorDelegates();
790 }
791 return dependencyCollectorDelegates;
792 }
793
794 protected Map<String, DependencyCollectorDelegate> createDependencyCollectorDelegates() {
795 RemoteRepositoryManager remoteRepositoryManager = getRemoteRepositoryManager();
796 ArtifactDescriptorReader artifactDescriptorReader = getArtifactDescriptorReader();
797 VersionRangeResolver versionRangeResolver = getVersionRangeResolver();
798 HashMap<String, DependencyCollectorDelegate> result = new HashMap<>();
799 result.put(
800 DfDependencyCollector.NAME,
801 new DfDependencyCollector(
802 remoteRepositoryManager,
803 artifactDescriptorReader,
804 versionRangeResolver,
805 getArtifactDecoratorFactories()));
806 result.put(
807 BfDependencyCollector.NAME,
808 new BfDependencyCollector(
809 remoteRepositoryManager,
810 artifactDescriptorReader,
811 versionRangeResolver,
812 getArtifactDecoratorFactories()));
813 return result;
814 }
815
816 private DependencyCollector dependencyCollector;
817
818 public final DependencyCollector getDependencyCollector() {
819 checkClosed();
820 if (dependencyCollector == null) {
821 dependencyCollector = createDependencyCollector();
822 }
823 return dependencyCollector;
824 }
825
826 protected DependencyCollector createDependencyCollector() {
827 return new DefaultDependencyCollector(getDependencyCollectorDelegates());
828 }
829
830 private Map<String, ArtifactResolverPostProcessor> artifactResolverPostProcessors;
831
832 public final Map<String, ArtifactResolverPostProcessor> getArtifactResolverPostProcessors() {
833 checkClosed();
834 if (artifactResolverPostProcessors == null) {
835 artifactResolverPostProcessors = createArtifactResolverPostProcessors();
836 }
837 return artifactResolverPostProcessors;
838 }
839
840 protected Map<String, ArtifactResolverPostProcessor> createArtifactResolverPostProcessors() {
841 HashMap<String, ArtifactResolverPostProcessor> result = new HashMap<>();
842 result.put(
843 TrustedChecksumsArtifactResolverPostProcessor.NAME,
844 new TrustedChecksumsArtifactResolverPostProcessor(
845 getChecksumAlgorithmFactorySelector(), getTrustedChecksumsSources()));
846 return result;
847 }
848
849 private ArtifactResolver artifactResolver;
850
851 public final ArtifactResolver getArtifactResolver() {
852 checkClosed();
853 if (artifactResolver == null) {
854 artifactResolver = createArtifactResolver();
855 }
856 return artifactResolver;
857 }
858
859 protected ArtifactResolver createArtifactResolver() {
860 return new DefaultArtifactResolver(
861 getPathProcessor(),
862 getRepositoryEventDispatcher(),
863 getVersionResolver(),
864 getUpdateCheckManager(),
865 getRepositoryConnectorProvider(),
866 getRemoteRepositoryManager(),
867 getSyncContextFactory(),
868 getOfflineController(),
869 getArtifactResolverPostProcessors(),
870 getRemoteRepositoryFilterManager());
871 }
872
873 private MetadataResolver metadataResolver;
874
875 public final MetadataResolver getMetadataResolver() {
876 checkClosed();
877 if (metadataResolver == null) {
878 metadataResolver = createMetadataResolver();
879 }
880 return metadataResolver;
881 }
882
883 protected MetadataResolver createMetadataResolver() {
884 return new DefaultMetadataResolver(
885 getRepositoryEventDispatcher(),
886 getUpdateCheckManager(),
887 getRepositoryConnectorProvider(),
888 getRemoteRepositoryManager(),
889 getSyncContextFactory(),
890 getOfflineController(),
891 getRemoteRepositoryFilterManager(),
892 getPathProcessor());
893 }
894
895 private VersionScheme versionScheme;
896
897 public final VersionScheme getVersionScheme() {
898 checkClosed();
899 if (versionScheme == null) {
900 versionScheme = createVersionScheme();
901 }
902 return versionScheme;
903 }
904
905 protected VersionScheme createVersionScheme() {
906 return new GenericVersionScheme();
907 }
908
909 private Map<String, ArtifactGeneratorFactory> artifactGeneratorFactories;
910
911 public final Map<String, ArtifactGeneratorFactory> getArtifactGeneratorFactories() {
912 checkClosed();
913 if (artifactGeneratorFactories == null) {
914 artifactGeneratorFactories = createArtifactGeneratorFactories();
915 }
916 return artifactGeneratorFactories;
917 }
918
919 protected Map<String, ArtifactGeneratorFactory> createArtifactGeneratorFactories() {
920
921 return new HashMap<>();
922 }
923
924 private Map<String, ArtifactDecoratorFactory> artifactDecoratorFactories;
925
926 public final Map<String, ArtifactDecoratorFactory> getArtifactDecoratorFactories() {
927 checkClosed();
928 if (artifactDecoratorFactories == null) {
929 artifactDecoratorFactories = createArtifactDecoratorFactories();
930 }
931 return artifactDecoratorFactories;
932 }
933
934 protected Map<String, ArtifactDecoratorFactory> createArtifactDecoratorFactories() {
935
936 return new HashMap<>();
937 }
938
939
940
941 private Map<String, MetadataGeneratorFactory> metadataGeneratorFactories;
942
943 public final Map<String, MetadataGeneratorFactory> getMetadataGeneratorFactories() {
944 checkClosed();
945 if (metadataGeneratorFactories == null) {
946 metadataGeneratorFactories = createMetadataGeneratorFactories();
947 }
948 return metadataGeneratorFactories;
949 }
950
951 protected Map<String, MetadataGeneratorFactory> createMetadataGeneratorFactories() {
952
953 HashMap<String, MetadataGeneratorFactory> result = new HashMap<>();
954 result.put(PluginsMetadataGeneratorFactory.NAME, new PluginsMetadataGeneratorFactory());
955 result.put(VersionsMetadataGeneratorFactory.NAME, new VersionsMetadataGeneratorFactory());
956 result.put(SnapshotMetadataGeneratorFactory.NAME, new SnapshotMetadataGeneratorFactory());
957 return result;
958 }
959
960 private LinkedHashMap<String, MavenArtifactRelocationSource> artifactRelocationSources;
961
962 public final LinkedHashMap<String, MavenArtifactRelocationSource> getMavenArtifactRelocationSources() {
963 checkClosed();
964 if (artifactRelocationSources == null) {
965 artifactRelocationSources = createMavenArtifactRelocationSources();
966 }
967 return artifactRelocationSources;
968 }
969
970 protected LinkedHashMap<String, MavenArtifactRelocationSource> createMavenArtifactRelocationSources() {
971
972 LinkedHashMap<String, MavenArtifactRelocationSource> result = new LinkedHashMap<>();
973 result.put(UserPropertiesArtifactRelocationSource.NAME, new UserPropertiesArtifactRelocationSource());
974 result.put(
975 DistributionManagementArtifactRelocationSource.NAME,
976 new DistributionManagementArtifactRelocationSource());
977 return result;
978 }
979
980 private ArtifactDescriptorReader artifactDescriptorReader;
981
982 public final ArtifactDescriptorReader getArtifactDescriptorReader() {
983 checkClosed();
984 if (artifactDescriptorReader == null) {
985 artifactDescriptorReader = createArtifactDescriptorReader();
986 }
987 return artifactDescriptorReader;
988 }
989
990 protected ArtifactDescriptorReader createArtifactDescriptorReader() {
991
992 return new DefaultArtifactDescriptorReader(
993 getVersionResolver(),
994 getArtifactResolver(),
995 getModelBuilder(),
996 getRepositoryEventDispatcher(),
997 getMavenArtifactRelocationSources());
998 }
999
1000 private VersionResolver versionResolver;
1001
1002 public final VersionResolver getVersionResolver() {
1003 checkClosed();
1004 if (versionResolver == null) {
1005 versionResolver = createVersionResolver();
1006 }
1007 return versionResolver;
1008 }
1009
1010 protected VersionResolver createVersionResolver() {
1011
1012 return new DefaultVersionResolver(
1013 getMetadataResolver(), getSyncContextFactory(), getRepositoryEventDispatcher());
1014 }
1015
1016 private VersionRangeResolver versionRangeResolver;
1017
1018 public final VersionRangeResolver getVersionRangeResolver() {
1019 checkClosed();
1020 if (versionRangeResolver == null) {
1021 versionRangeResolver = createVersionRangeResolver();
1022 }
1023 return versionRangeResolver;
1024 }
1025
1026 protected VersionRangeResolver createVersionRangeResolver() {
1027
1028 return new DefaultVersionRangeResolver(
1029 getMetadataResolver(), getSyncContextFactory(), getRepositoryEventDispatcher(), getVersionScheme());
1030 }
1031
1032 private ModelBuilder modelBuilder;
1033
1034 public final ModelBuilder getModelBuilder() {
1035 checkClosed();
1036 if (modelBuilder == null) {
1037 modelBuilder = createModelBuilder();
1038 }
1039 return modelBuilder;
1040 }
1041
1042 protected ModelBuilder createModelBuilder() {
1043
1044 DefaultModelProcessor modelProcessor = new DefaultModelProcessor(new DefaultModelXmlFactory(), List.of());
1045 return new DefaultModelBuilder(
1046 modelProcessor,
1047 new DefaultModelValidator(),
1048 new DefaultModelNormalizer(),
1049 new DefaultModelInterpolator(
1050 new DefaultPathTranslator(),
1051 new DefaultUrlNormalizer(),
1052 new DefaultRootLocator(),
1053 new DefaultInterpolator()),
1054 new DefaultModelPathTranslator(new DefaultPathTranslator()),
1055 new DefaultModelUrlNormalizer(new DefaultUrlNormalizer()),
1056 new DefaultSuperPomProvider(modelProcessor),
1057 new DefaultInheritanceAssembler(),
1058 new DefaultProfileSelector(),
1059 new DefaultProfileInjector(),
1060 new DefaultPluginManagementInjector(),
1061 new DefaultDependencyManagementInjector(),
1062 new DefaultDependencyManagementImporter(),
1063 new DefaultPluginConfigurationExpander(),
1064 new ProfileActivationFilePathInterpolator(
1065 new DefaultPathTranslator(), new DefaultRootLocator(), new DefaultInterpolator()),
1066 new DefaultModelVersionParser(getVersionScheme()),
1067 List.of(),
1068 new DefaultModelCacheFactory(),
1069 new org.apache.maven.internal.impl.resolver.DefaultModelResolver(),
1070 new DefaultInterpolator());
1071 }
1072
1073 private RepositorySystem repositorySystem;
1074
1075 public final RepositorySystem getRepositorySystem() {
1076 checkClosed();
1077 if (repositorySystem == null) {
1078 repositorySystem = createRepositorySystem();
1079 }
1080 return repositorySystem;
1081 }
1082
1083 protected RepositorySystem createRepositorySystem() {
1084 return new DefaultRepositorySystem(
1085 getVersionResolver(),
1086 getVersionRangeResolver(),
1087 getArtifactResolver(),
1088 getMetadataResolver(),
1089 getArtifactDescriptorReader(),
1090 getDependencyCollector(),
1091 getInstaller(),
1092 getDeployer(),
1093 getLocalRepositoryProvider(),
1094 getSyncContextFactory(),
1095 getRemoteRepositoryManager(),
1096 getRepositorySystemLifecycle(),
1097 getArtifactDecoratorFactories());
1098 }
1099
1100 @Override
1101 public RepositorySystem get() {
1102 return getRepositorySystem();
1103 }
1104 }