001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 */ 019package org.eclipse.aether.supplier; 020 021import java.util.HashMap; 022import java.util.LinkedHashMap; 023import java.util.Map; 024import java.util.function.Supplier; 025 026import org.apache.maven.model.building.DefaultModelBuilderFactory; 027import org.apache.maven.model.building.ModelBuilder; 028import org.apache.maven.repository.internal.*; 029import org.apache.maven.repository.internal.relocation.DistributionManagementArtifactRelocationSource; 030import org.apache.maven.repository.internal.relocation.UserPropertiesArtifactRelocationSource; 031import org.eclipse.aether.RepositoryListener; 032import org.eclipse.aether.RepositorySystem; 033import org.eclipse.aether.connector.basic.BasicRepositoryConnectorFactory; 034import org.eclipse.aether.impl.ArtifactDescriptorReader; 035import org.eclipse.aether.impl.ArtifactResolver; 036import org.eclipse.aether.impl.DependencyCollector; 037import org.eclipse.aether.impl.Deployer; 038import org.eclipse.aether.impl.Installer; 039import org.eclipse.aether.impl.LocalRepositoryProvider; 040import org.eclipse.aether.impl.MetadataGeneratorFactory; 041import org.eclipse.aether.impl.MetadataResolver; 042import org.eclipse.aether.impl.OfflineController; 043import org.eclipse.aether.impl.RemoteRepositoryFilterManager; 044import org.eclipse.aether.impl.RemoteRepositoryManager; 045import org.eclipse.aether.impl.RepositoryConnectorProvider; 046import org.eclipse.aether.impl.RepositoryEventDispatcher; 047import org.eclipse.aether.impl.RepositorySystemLifecycle; 048import org.eclipse.aether.impl.UpdateCheckManager; 049import org.eclipse.aether.impl.UpdatePolicyAnalyzer; 050import org.eclipse.aether.impl.VersionRangeResolver; 051import org.eclipse.aether.impl.VersionResolver; 052import org.eclipse.aether.internal.impl.DefaultArtifactResolver; 053import org.eclipse.aether.internal.impl.DefaultChecksumPolicyProvider; 054import org.eclipse.aether.internal.impl.DefaultDeployer; 055import org.eclipse.aether.internal.impl.DefaultFileProcessor; 056import org.eclipse.aether.internal.impl.DefaultInstaller; 057import org.eclipse.aether.internal.impl.DefaultLocalPathComposer; 058import org.eclipse.aether.internal.impl.DefaultLocalPathPrefixComposerFactory; 059import org.eclipse.aether.internal.impl.DefaultLocalRepositoryProvider; 060import org.eclipse.aether.internal.impl.DefaultMetadataResolver; 061import org.eclipse.aether.internal.impl.DefaultOfflineController; 062import org.eclipse.aether.internal.impl.DefaultRemoteRepositoryManager; 063import org.eclipse.aether.internal.impl.DefaultRepositoryConnectorProvider; 064import org.eclipse.aether.internal.impl.DefaultRepositoryEventDispatcher; 065import org.eclipse.aether.internal.impl.DefaultRepositoryLayoutProvider; 066import org.eclipse.aether.internal.impl.DefaultRepositorySystem; 067import org.eclipse.aether.internal.impl.DefaultRepositorySystemLifecycle; 068import org.eclipse.aether.internal.impl.DefaultTrackingFileManager; 069import org.eclipse.aether.internal.impl.DefaultTransporterProvider; 070import org.eclipse.aether.internal.impl.DefaultUpdateCheckManager; 071import org.eclipse.aether.internal.impl.DefaultUpdatePolicyAnalyzer; 072import org.eclipse.aether.internal.impl.EnhancedLocalRepositoryManagerFactory; 073import org.eclipse.aether.internal.impl.LocalPathComposer; 074import org.eclipse.aether.internal.impl.LocalPathPrefixComposerFactory; 075import org.eclipse.aether.internal.impl.Maven2RepositoryLayoutFactory; 076import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory; 077import org.eclipse.aether.internal.impl.TrackingFileManager; 078import org.eclipse.aether.internal.impl.checksum.DefaultChecksumAlgorithmFactorySelector; 079import org.eclipse.aether.internal.impl.checksum.Md5ChecksumAlgorithmFactory; 080import org.eclipse.aether.internal.impl.checksum.Sha1ChecksumAlgorithmFactory; 081import org.eclipse.aether.internal.impl.checksum.Sha256ChecksumAlgorithmFactory; 082import org.eclipse.aether.internal.impl.checksum.Sha512ChecksumAlgorithmFactory; 083import org.eclipse.aether.internal.impl.checksum.SparseDirectoryTrustedChecksumsSource; 084import org.eclipse.aether.internal.impl.checksum.SummaryFileTrustedChecksumsSource; 085import org.eclipse.aether.internal.impl.checksum.TrustedToProvidedChecksumsSourceAdapter; 086import org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector; 087import org.eclipse.aether.internal.impl.collect.DependencyCollectorDelegate; 088import org.eclipse.aether.internal.impl.collect.bf.BfDependencyCollector; 089import org.eclipse.aether.internal.impl.collect.df.DfDependencyCollector; 090import org.eclipse.aether.internal.impl.filter.DefaultRemoteRepositoryFilterManager; 091import org.eclipse.aether.internal.impl.filter.GroupIdRemoteRepositoryFilterSource; 092import org.eclipse.aether.internal.impl.filter.PrefixesRemoteRepositoryFilterSource; 093import org.eclipse.aether.internal.impl.resolution.TrustedChecksumsArtifactResolverPostProcessor; 094import org.eclipse.aether.internal.impl.synccontext.DefaultSyncContextFactory; 095import org.eclipse.aether.internal.impl.synccontext.named.NameMapper; 096import org.eclipse.aether.internal.impl.synccontext.named.NameMappers; 097import org.eclipse.aether.internal.impl.synccontext.named.NamedLockFactoryAdapterFactory; 098import org.eclipse.aether.internal.impl.synccontext.named.NamedLockFactoryAdapterFactoryImpl; 099import org.eclipse.aether.named.NamedLockFactory; 100import org.eclipse.aether.named.providers.FileLockNamedLockFactory; 101import org.eclipse.aether.named.providers.LocalReadWriteLockNamedLockFactory; 102import org.eclipse.aether.named.providers.LocalSemaphoreNamedLockFactory; 103import org.eclipse.aether.named.providers.NoopNamedLockFactory; 104import org.eclipse.aether.spi.checksums.ProvidedChecksumsSource; 105import org.eclipse.aether.spi.checksums.TrustedChecksumsSource; 106import org.eclipse.aether.spi.connector.RepositoryConnectorFactory; 107import org.eclipse.aether.spi.connector.checksum.ChecksumAlgorithmFactory; 108import org.eclipse.aether.spi.connector.checksum.ChecksumAlgorithmFactorySelector; 109import org.eclipse.aether.spi.connector.checksum.ChecksumPolicyProvider; 110import org.eclipse.aether.spi.connector.filter.RemoteRepositoryFilterSource; 111import org.eclipse.aether.spi.connector.layout.RepositoryLayoutFactory; 112import org.eclipse.aether.spi.connector.layout.RepositoryLayoutProvider; 113import org.eclipse.aether.spi.connector.transport.TransporterFactory; 114import org.eclipse.aether.spi.connector.transport.TransporterProvider; 115import org.eclipse.aether.spi.io.FileProcessor; 116import org.eclipse.aether.spi.localrepo.LocalRepositoryManagerFactory; 117import org.eclipse.aether.spi.resolution.ArtifactResolverPostProcessor; 118import org.eclipse.aether.spi.synccontext.SyncContextFactory; 119import org.eclipse.aether.transport.apache.ApacheTransporterFactory; 120import org.eclipse.aether.transport.file.FileTransporterFactory; 121import org.eclipse.aether.util.version.GenericVersionScheme; 122import org.eclipse.aether.version.VersionScheme; 123 124/** 125 * A simple {@link Supplier} of {@link org.eclipse.aether.RepositorySystem} instances, that on each call supplies newly 126 * constructed instance. For proper shut down, use {@link RepositorySystem#shutdown()} method on supplied instance(s). 127 * <p> 128 * Extend this class and override methods to customize, if needed. 129 * 130 * @since 1.9.15 131 */ 132public class RepositorySystemSupplier implements Supplier<RepositorySystem> { 133 protected FileProcessor getFileProcessor() { 134 return new DefaultFileProcessor(); 135 } 136 137 protected TrackingFileManager getTrackingFileManager() { 138 return new DefaultTrackingFileManager(); 139 } 140 141 protected LocalPathComposer getLocalPathComposer() { 142 return new DefaultLocalPathComposer(); 143 } 144 145 protected LocalPathPrefixComposerFactory getLocalPathPrefixComposerFactory() { 146 return new DefaultLocalPathPrefixComposerFactory(); 147 } 148 149 protected RepositorySystemLifecycle getRepositorySystemLifecycle() { 150 return new DefaultRepositorySystemLifecycle(); 151 } 152 153 protected OfflineController getOfflineController() { 154 return new DefaultOfflineController(); 155 } 156 157 protected UpdatePolicyAnalyzer getUpdatePolicyAnalyzer() { 158 return new DefaultUpdatePolicyAnalyzer(); 159 } 160 161 protected ChecksumPolicyProvider getChecksumPolicyProvider() { 162 return new DefaultChecksumPolicyProvider(); 163 } 164 165 protected UpdateCheckManager getUpdateCheckManager( 166 TrackingFileManager trackingFileManager, UpdatePolicyAnalyzer updatePolicyAnalyzer) { 167 return new DefaultUpdateCheckManager(trackingFileManager, updatePolicyAnalyzer); 168 } 169 170 protected Map<String, NamedLockFactory> getNamedLockFactories() { 171 HashMap<String, NamedLockFactory> result = new HashMap<>(); 172 result.put(NoopNamedLockFactory.NAME, new NoopNamedLockFactory()); 173 result.put(LocalReadWriteLockNamedLockFactory.NAME, new LocalReadWriteLockNamedLockFactory()); 174 result.put(LocalSemaphoreNamedLockFactory.NAME, new LocalSemaphoreNamedLockFactory()); 175 result.put(FileLockNamedLockFactory.NAME, new FileLockNamedLockFactory()); 176 return result; 177 } 178 179 protected Map<String, NameMapper> getNameMappers() { 180 HashMap<String, NameMapper> result = new HashMap<>(); 181 result.put(NameMappers.STATIC_NAME, NameMappers.staticNameMapper()); 182 result.put(NameMappers.GAV_NAME, NameMappers.gavNameMapper()); 183 result.put(NameMappers.DISCRIMINATING_NAME, NameMappers.discriminatingNameMapper()); 184 result.put(NameMappers.FILE_GAV_NAME, NameMappers.fileGavNameMapper()); 185 result.put(NameMappers.FILE_HGAV_NAME, NameMappers.fileHashingGavNameMapper()); 186 return result; 187 } 188 189 protected NamedLockFactoryAdapterFactory getNamedLockFactoryAdapterFactory( 190 Map<String, NamedLockFactory> namedLockFactories, 191 Map<String, NameMapper> nameMappers, 192 RepositorySystemLifecycle repositorySystemLifecycle) { 193 return new NamedLockFactoryAdapterFactoryImpl(namedLockFactories, nameMappers, repositorySystemLifecycle); 194 } 195 196 protected SyncContextFactory getSyncContextFactory(NamedLockFactoryAdapterFactory namedLockFactoryAdapterFactory) { 197 return new DefaultSyncContextFactory(namedLockFactoryAdapterFactory); 198 } 199 200 protected Map<String, ChecksumAlgorithmFactory> getChecksumAlgorithmFactories() { 201 HashMap<String, ChecksumAlgorithmFactory> result = new HashMap<>(); 202 result.put(Sha512ChecksumAlgorithmFactory.NAME, new Sha512ChecksumAlgorithmFactory()); 203 result.put(Sha256ChecksumAlgorithmFactory.NAME, new Sha256ChecksumAlgorithmFactory()); 204 result.put(Sha1ChecksumAlgorithmFactory.NAME, new Sha1ChecksumAlgorithmFactory()); 205 result.put(Md5ChecksumAlgorithmFactory.NAME, new Md5ChecksumAlgorithmFactory()); 206 return result; 207 } 208 209 protected ChecksumAlgorithmFactorySelector getChecksumAlgorithmFactorySelector( 210 Map<String, ChecksumAlgorithmFactory> checksumAlgorithmFactories) { 211 return new DefaultChecksumAlgorithmFactorySelector(checksumAlgorithmFactories); 212 } 213 214 protected Map<String, RepositoryLayoutFactory> getRepositoryLayoutFactories( 215 ChecksumAlgorithmFactorySelector checksumAlgorithmFactorySelector) { 216 HashMap<String, RepositoryLayoutFactory> result = new HashMap<>(); 217 result.put( 218 Maven2RepositoryLayoutFactory.NAME, 219 new Maven2RepositoryLayoutFactory(checksumAlgorithmFactorySelector)); 220 return result; 221 } 222 223 protected RepositoryLayoutProvider getRepositoryLayoutProvider( 224 Map<String, RepositoryLayoutFactory> repositoryLayoutFactories) { 225 return new DefaultRepositoryLayoutProvider(repositoryLayoutFactories); 226 } 227 228 protected LocalRepositoryProvider getLocalRepositoryProvider( 229 LocalPathComposer localPathComposer, 230 TrackingFileManager trackingFileManager, 231 LocalPathPrefixComposerFactory localPathPrefixComposerFactory) { 232 HashMap<String, LocalRepositoryManagerFactory> localRepositoryProviders = new HashMap<>(2); 233 localRepositoryProviders.put( 234 SimpleLocalRepositoryManagerFactory.NAME, new SimpleLocalRepositoryManagerFactory(localPathComposer)); 235 localRepositoryProviders.put( 236 EnhancedLocalRepositoryManagerFactory.NAME, 237 new EnhancedLocalRepositoryManagerFactory( 238 localPathComposer, trackingFileManager, localPathPrefixComposerFactory)); 239 return new DefaultLocalRepositoryProvider(localRepositoryProviders); 240 } 241 242 protected RemoteRepositoryManager getRemoteRepositoryManager( 243 UpdatePolicyAnalyzer updatePolicyAnalyzer, ChecksumPolicyProvider checksumPolicyProvider) { 244 return new DefaultRemoteRepositoryManager(updatePolicyAnalyzer, checksumPolicyProvider); 245 } 246 247 protected Map<String, RemoteRepositoryFilterSource> getRemoteRepositoryFilterSources( 248 RepositorySystemLifecycle repositorySystemLifecycle, RepositoryLayoutProvider repositoryLayoutProvider) { 249 HashMap<String, RemoteRepositoryFilterSource> result = new HashMap<>(); 250 result.put( 251 GroupIdRemoteRepositoryFilterSource.NAME, 252 new GroupIdRemoteRepositoryFilterSource(repositorySystemLifecycle)); 253 result.put( 254 PrefixesRemoteRepositoryFilterSource.NAME, 255 new PrefixesRemoteRepositoryFilterSource(repositoryLayoutProvider)); 256 return result; 257 } 258 259 protected RemoteRepositoryFilterManager getRemoteRepositoryFilterManager( 260 Map<String, RemoteRepositoryFilterSource> remoteRepositoryFilterSources) { 261 return new DefaultRemoteRepositoryFilterManager(remoteRepositoryFilterSources); 262 } 263 264 protected Map<String, RepositoryListener> getRepositoryListeners() { 265 return new HashMap<>(); 266 } 267 268 protected RepositoryEventDispatcher getRepositoryEventDispatcher( 269 Map<String, RepositoryListener> repositoryListeners) { 270 return new DefaultRepositoryEventDispatcher(repositoryListeners); 271 } 272 273 protected Map<String, TrustedChecksumsSource> getTrustedChecksumsSources( 274 FileProcessor fileProcessor, 275 LocalPathComposer localPathComposer, 276 RepositorySystemLifecycle repositorySystemLifecycle) { 277 HashMap<String, TrustedChecksumsSource> result = new HashMap<>(); 278 result.put( 279 SparseDirectoryTrustedChecksumsSource.NAME, 280 new SparseDirectoryTrustedChecksumsSource(fileProcessor, localPathComposer)); 281 result.put( 282 SummaryFileTrustedChecksumsSource.NAME, 283 new SummaryFileTrustedChecksumsSource(localPathComposer, repositorySystemLifecycle)); 284 return result; 285 } 286 287 protected Map<String, ProvidedChecksumsSource> getProvidedChecksumsSources( 288 Map<String, TrustedChecksumsSource> trustedChecksumsSources) { 289 HashMap<String, ProvidedChecksumsSource> result = new HashMap<>(); 290 result.put( 291 TrustedToProvidedChecksumsSourceAdapter.NAME, 292 new TrustedToProvidedChecksumsSourceAdapter(trustedChecksumsSources)); 293 return result; 294 } 295 296 protected Map<String, TransporterFactory> getTransporterFactories() { 297 HashMap<String, TransporterFactory> result = new HashMap<>(); 298 result.put(FileTransporterFactory.NAME, new FileTransporterFactory()); 299 result.put(ApacheTransporterFactory.NAME, new ApacheTransporterFactory()); 300 return result; 301 } 302 303 protected TransporterProvider getTransporterProvider(Map<String, TransporterFactory> transporterFactories) { 304 return new DefaultTransporterProvider(transporterFactories); 305 } 306 307 protected BasicRepositoryConnectorFactory getBasicRepositoryConnectorFactory( 308 TransporterProvider transporterProvider, 309 RepositoryLayoutProvider repositoryLayoutProvider, 310 ChecksumPolicyProvider checksumPolicyProvider, 311 FileProcessor fileProcessor, 312 Map<String, ProvidedChecksumsSource> providedChecksumsSources) { 313 return new BasicRepositoryConnectorFactory( 314 transporterProvider, 315 repositoryLayoutProvider, 316 checksumPolicyProvider, 317 fileProcessor, 318 providedChecksumsSources); 319 } 320 321 protected Map<String, RepositoryConnectorFactory> getRepositoryConnectorFactories( 322 BasicRepositoryConnectorFactory basicRepositoryConnectorFactory) { 323 HashMap<String, RepositoryConnectorFactory> result = new HashMap<>(); 324 result.put(BasicRepositoryConnectorFactory.NAME, basicRepositoryConnectorFactory); 325 return result; 326 } 327 328 protected RepositoryConnectorProvider getRepositoryConnectorProvider( 329 Map<String, RepositoryConnectorFactory> repositoryConnectorFactories, 330 RemoteRepositoryFilterManager remoteRepositoryFilterManager) { 331 return new DefaultRepositoryConnectorProvider(repositoryConnectorFactories, remoteRepositoryFilterManager); 332 } 333 334 protected Installer getInstaller( 335 FileProcessor fileProcessor, 336 RepositoryEventDispatcher repositoryEventDispatcher, 337 Map<String, MetadataGeneratorFactory> metadataGeneratorFactories, 338 SyncContextFactory syncContextFactory) { 339 return new DefaultInstaller( 340 fileProcessor, repositoryEventDispatcher, metadataGeneratorFactories, syncContextFactory); 341 } 342 343 @SuppressWarnings("checkstyle:parameternumber") 344 protected Deployer getDeployer( 345 FileProcessor fileProcessor, 346 RepositoryEventDispatcher repositoryEventDispatcher, 347 RepositoryConnectorProvider repositoryConnectorProvider, 348 RemoteRepositoryManager remoteRepositoryManager, 349 UpdateCheckManager updateCheckManager, 350 Map<String, MetadataGeneratorFactory> metadataGeneratorFactories, 351 SyncContextFactory syncContextFactory, 352 OfflineController offlineController) { 353 return new DefaultDeployer( 354 fileProcessor, 355 repositoryEventDispatcher, 356 repositoryConnectorProvider, 357 remoteRepositoryManager, 358 updateCheckManager, 359 metadataGeneratorFactories, 360 syncContextFactory, 361 offlineController); 362 } 363 364 protected Map<String, DependencyCollectorDelegate> getDependencyCollectorDelegates( 365 RemoteRepositoryManager remoteRepositoryManager, 366 ArtifactDescriptorReader artifactDescriptorReader, 367 VersionRangeResolver versionRangeResolver) { 368 HashMap<String, DependencyCollectorDelegate> result = new HashMap<>(); 369 result.put( 370 DfDependencyCollector.NAME, 371 new DfDependencyCollector(remoteRepositoryManager, artifactDescriptorReader, versionRangeResolver)); 372 result.put( 373 BfDependencyCollector.NAME, 374 new BfDependencyCollector(remoteRepositoryManager, artifactDescriptorReader, versionRangeResolver)); 375 return result; 376 } 377 378 protected DependencyCollector getDependencyCollector( 379 Map<String, DependencyCollectorDelegate> dependencyCollectorDelegates) { 380 return new DefaultDependencyCollector(dependencyCollectorDelegates); 381 } 382 383 protected Map<String, ArtifactResolverPostProcessor> getArtifactResolverPostProcessors( 384 ChecksumAlgorithmFactorySelector checksumAlgorithmFactorySelector, 385 Map<String, TrustedChecksumsSource> trustedChecksumsSources) { 386 HashMap<String, ArtifactResolverPostProcessor> result = new HashMap<>(); 387 result.put( 388 TrustedChecksumsArtifactResolverPostProcessor.NAME, 389 new TrustedChecksumsArtifactResolverPostProcessor( 390 checksumAlgorithmFactorySelector, trustedChecksumsSources)); 391 return result; 392 } 393 394 @SuppressWarnings("checkstyle:parameternumber") 395 protected ArtifactResolver getArtifactResolver( 396 FileProcessor fileProcessor, 397 RepositoryEventDispatcher repositoryEventDispatcher, 398 VersionResolver versionResolver, 399 UpdateCheckManager updateCheckManager, 400 RepositoryConnectorProvider repositoryConnectorProvider, 401 RemoteRepositoryManager remoteRepositoryManager, 402 SyncContextFactory syncContextFactory, 403 OfflineController offlineController, 404 Map<String, ArtifactResolverPostProcessor> artifactResolverPostProcessors, 405 RemoteRepositoryFilterManager remoteRepositoryFilterManager) { 406 return new DefaultArtifactResolver( 407 fileProcessor, 408 repositoryEventDispatcher, 409 versionResolver, 410 updateCheckManager, 411 repositoryConnectorProvider, 412 remoteRepositoryManager, 413 syncContextFactory, 414 offlineController, 415 artifactResolverPostProcessors, 416 remoteRepositoryFilterManager); 417 } 418 419 protected MetadataResolver getMetadataResolver( 420 RepositoryEventDispatcher repositoryEventDispatcher, 421 UpdateCheckManager updateCheckManager, 422 RepositoryConnectorProvider repositoryConnectorProvider, 423 RemoteRepositoryManager remoteRepositoryManager, 424 SyncContextFactory syncContextFactory, 425 OfflineController offlineController, 426 RemoteRepositoryFilterManager remoteRepositoryFilterManager) { 427 return new DefaultMetadataResolver( 428 repositoryEventDispatcher, 429 updateCheckManager, 430 repositoryConnectorProvider, 431 remoteRepositoryManager, 432 syncContextFactory, 433 offlineController, 434 remoteRepositoryFilterManager); 435 } 436 437 protected VersionScheme getVersionScheme() { 438 return new GenericVersionScheme(); 439 } 440 441 // Maven provided 442 443 protected Map<String, MetadataGeneratorFactory> getMetadataGeneratorFactories() { 444 // from maven-resolver-provider 445 HashMap<String, MetadataGeneratorFactory> result = new HashMap<>(); 446 result.put(PluginsMetadataGeneratorFactory.NAME, new PluginsMetadataGeneratorFactory()); 447 result.put(VersionsMetadataGeneratorFactory.NAME, new VersionsMetadataGeneratorFactory()); 448 result.put(SnapshotMetadataGeneratorFactory.NAME, new SnapshotMetadataGeneratorFactory()); 449 return result; 450 } 451 452 protected LinkedHashMap<String, MavenArtifactRelocationSource> getMavenArtifactRelocationSource() { 453 // from maven-resolver-provider 454 LinkedHashMap<String, MavenArtifactRelocationSource> result = new LinkedHashMap<>(); 455 result.put(UserPropertiesArtifactRelocationSource.NAME, new UserPropertiesArtifactRelocationSource()); 456 result.put( 457 DistributionManagementArtifactRelocationSource.NAME, 458 new DistributionManagementArtifactRelocationSource()); 459 return result; 460 } 461 462 @SuppressWarnings("checkstyle:parameternumber") 463 protected ArtifactDescriptorReader getArtifactDescriptorReader( 464 RemoteRepositoryManager remoteRepositoryManager, 465 VersionResolver versionResolver, 466 VersionRangeResolver versionRangeResolver, 467 ArtifactResolver artifactResolver, 468 ModelBuilder modelBuilder, 469 RepositoryEventDispatcher repositoryEventDispatcher, 470 ModelCacheFactory modelCacheFactory, 471 LinkedHashMap<String, MavenArtifactRelocationSource> artifactRelocationSources) { 472 // from maven-resolver-provider 473 return new DefaultArtifactDescriptorReader( 474 remoteRepositoryManager, 475 versionResolver, 476 versionRangeResolver, 477 artifactResolver, 478 modelBuilder, 479 repositoryEventDispatcher, 480 modelCacheFactory, 481 artifactRelocationSources); 482 } 483 484 protected VersionResolver getVersionResolver( 485 MetadataResolver metadataResolver, 486 SyncContextFactory syncContextFactory, 487 RepositoryEventDispatcher repositoryEventDispatcher) { 488 // from maven-resolver-provider 489 return new DefaultVersionResolver(metadataResolver, syncContextFactory, repositoryEventDispatcher); 490 } 491 492 protected VersionRangeResolver getVersionRangeResolver( 493 MetadataResolver metadataResolver, 494 SyncContextFactory syncContextFactory, 495 RepositoryEventDispatcher repositoryEventDispatcher, 496 VersionScheme versionScheme) { 497 // from maven-resolver-provider 498 return new DefaultVersionRangeResolver( 499 metadataResolver, syncContextFactory, repositoryEventDispatcher, versionScheme); 500 } 501 502 protected ModelBuilder getModelBuilder() { 503 // from maven-model-builder 504 return new DefaultModelBuilderFactory().newInstance(); 505 } 506 507 protected ModelCacheFactory getModelCacheFactory() { 508 // from maven-resolver-provider 509 return new DefaultModelCacheFactory(); 510 } 511 512 @Override 513 public RepositorySystem get() { 514 FileProcessor fileProcessor = getFileProcessor(); 515 TrackingFileManager trackingFileManager = getTrackingFileManager(); 516 LocalPathComposer localPathComposer = getLocalPathComposer(); 517 LocalPathPrefixComposerFactory localPathPrefixComposerFactory = getLocalPathPrefixComposerFactory(); 518 RepositorySystemLifecycle repositorySystemLifecycle = getRepositorySystemLifecycle(); 519 OfflineController offlineController = getOfflineController(); 520 UpdatePolicyAnalyzer updatePolicyAnalyzer = getUpdatePolicyAnalyzer(); 521 ChecksumPolicyProvider checksumPolicyProvider = getChecksumPolicyProvider(); 522 523 UpdateCheckManager updateCheckManager = getUpdateCheckManager(trackingFileManager, updatePolicyAnalyzer); 524 525 Map<String, NamedLockFactory> namedLockFactories = getNamedLockFactories(); 526 Map<String, NameMapper> nameMappers = getNameMappers(); 527 NamedLockFactoryAdapterFactory namedLockFactoryAdapterFactory = 528 getNamedLockFactoryAdapterFactory(namedLockFactories, nameMappers, repositorySystemLifecycle); 529 SyncContextFactory syncContextFactory = getSyncContextFactory(namedLockFactoryAdapterFactory); 530 531 Map<String, ChecksumAlgorithmFactory> checksumAlgorithmFactories = getChecksumAlgorithmFactories(); 532 ChecksumAlgorithmFactorySelector checksumAlgorithmFactorySelector = 533 getChecksumAlgorithmFactorySelector(checksumAlgorithmFactories); 534 535 Map<String, RepositoryLayoutFactory> repositoryLayoutFactories = 536 getRepositoryLayoutFactories(checksumAlgorithmFactorySelector); 537 RepositoryLayoutProvider repositoryLayoutProvider = getRepositoryLayoutProvider(repositoryLayoutFactories); 538 539 LocalRepositoryProvider localRepositoryProvider = 540 getLocalRepositoryProvider(localPathComposer, trackingFileManager, localPathPrefixComposerFactory); 541 542 RemoteRepositoryManager remoteRepositoryManager = 543 getRemoteRepositoryManager(updatePolicyAnalyzer, checksumPolicyProvider); 544 Map<String, RemoteRepositoryFilterSource> remoteRepositoryFilterSources = 545 getRemoteRepositoryFilterSources(repositorySystemLifecycle, repositoryLayoutProvider); 546 RemoteRepositoryFilterManager remoteRepositoryFilterManager = 547 getRemoteRepositoryFilterManager(remoteRepositoryFilterSources); 548 549 Map<String, RepositoryListener> repositoryListeners = getRepositoryListeners(); 550 RepositoryEventDispatcher repositoryEventDispatcher = getRepositoryEventDispatcher(repositoryListeners); 551 552 Map<String, TrustedChecksumsSource> trustedChecksumsSources = 553 getTrustedChecksumsSources(fileProcessor, localPathComposer, repositorySystemLifecycle); 554 Map<String, ProvidedChecksumsSource> providedChecksumsSources = 555 getProvidedChecksumsSources(trustedChecksumsSources); 556 557 Map<String, TransporterFactory> transporterFactories = getTransporterFactories(); 558 TransporterProvider transporterProvider = getTransporterProvider(transporterFactories); 559 560 BasicRepositoryConnectorFactory basic = getBasicRepositoryConnectorFactory( 561 transporterProvider, 562 repositoryLayoutProvider, 563 checksumPolicyProvider, 564 fileProcessor, 565 providedChecksumsSources); 566 Map<String, RepositoryConnectorFactory> repositoryConnectorFactories = getRepositoryConnectorFactories(basic); 567 RepositoryConnectorProvider repositoryConnectorProvider = 568 getRepositoryConnectorProvider(repositoryConnectorFactories, remoteRepositoryFilterManager); 569 570 Map<String, MetadataGeneratorFactory> metadataGeneratorFactories = getMetadataGeneratorFactories(); 571 572 Installer installer = 573 getInstaller(fileProcessor, repositoryEventDispatcher, metadataGeneratorFactories, syncContextFactory); 574 Deployer deployer = getDeployer( 575 fileProcessor, 576 repositoryEventDispatcher, 577 repositoryConnectorProvider, 578 remoteRepositoryManager, 579 updateCheckManager, 580 metadataGeneratorFactories, 581 syncContextFactory, 582 offlineController); 583 584 MetadataResolver metadataResolver = getMetadataResolver( 585 repositoryEventDispatcher, 586 updateCheckManager, 587 repositoryConnectorProvider, 588 remoteRepositoryManager, 589 syncContextFactory, 590 offlineController, 591 remoteRepositoryFilterManager); 592 593 VersionScheme versionScheme = getVersionScheme(); 594 VersionResolver versionResolver = 595 getVersionResolver(metadataResolver, syncContextFactory, repositoryEventDispatcher); 596 VersionRangeResolver versionRangeResolver = 597 getVersionRangeResolver(metadataResolver, syncContextFactory, repositoryEventDispatcher, versionScheme); 598 599 Map<String, ArtifactResolverPostProcessor> artifactResolverPostProcessors = 600 getArtifactResolverPostProcessors(checksumAlgorithmFactorySelector, trustedChecksumsSources); 601 ArtifactResolver artifactResolver = getArtifactResolver( 602 fileProcessor, 603 repositoryEventDispatcher, 604 versionResolver, 605 updateCheckManager, 606 repositoryConnectorProvider, 607 remoteRepositoryManager, 608 syncContextFactory, 609 offlineController, 610 artifactResolverPostProcessors, 611 remoteRepositoryFilterManager); 612 613 ModelBuilder modelBuilder = getModelBuilder(); 614 ModelCacheFactory modelCacheFactory = getModelCacheFactory(); 615 LinkedHashMap<String, MavenArtifactRelocationSource> mavenArtifactRelocationSources = 616 getMavenArtifactRelocationSource(); 617 618 ArtifactDescriptorReader artifactDescriptorReader = getArtifactDescriptorReader( 619 remoteRepositoryManager, 620 versionResolver, 621 versionRangeResolver, 622 artifactResolver, 623 modelBuilder, 624 repositoryEventDispatcher, 625 modelCacheFactory, 626 mavenArtifactRelocationSources); 627 628 Map<String, DependencyCollectorDelegate> dependencyCollectorDelegates = getDependencyCollectorDelegates( 629 remoteRepositoryManager, artifactDescriptorReader, versionRangeResolver); 630 DependencyCollector dependencyCollector = getDependencyCollector(dependencyCollectorDelegates); 631 632 return new DefaultRepositorySystem( 633 versionResolver, 634 versionRangeResolver, 635 artifactResolver, 636 metadataResolver, 637 artifactDescriptorReader, 638 dependencyCollector, 639 installer, 640 deployer, 641 localRepositoryProvider, 642 syncContextFactory, 643 remoteRepositoryManager, 644 repositorySystemLifecycle); 645 } 646}