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