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