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