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