1 package org.apache.maven.repository.internal;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.util.Collections;
23 import java.util.HashSet;
24 import java.util.Set;
25 import javax.inject.Named;
26 import javax.inject.Singleton;
27 import com.google.inject.AbstractModule;
28 import com.google.inject.Provides;
29 import com.google.inject.name.Names;
30 import org.apache.maven.model.building.DefaultModelBuilderFactory;
31 import org.apache.maven.model.building.ModelBuilder;
32 import org.eclipse.aether.impl.ArtifactDescriptorReader;
33 import org.eclipse.aether.impl.MetadataGeneratorFactory;
34 import org.eclipse.aether.impl.VersionRangeResolver;
35 import org.eclipse.aether.impl.VersionResolver;
36 import org.eclipse.aether.impl.guice.AetherModule;
37
38
39
40
41 public final class MavenResolverModule
42 extends AbstractModule
43 {
44
45 @Override
46 protected void configure()
47 {
48 install( new AetherModule() );
49 bind( ArtifactDescriptorReader.class ).to( DefaultArtifactDescriptorReader.class ).in( Singleton.class );
50 bind( VersionResolver.class ).to( DefaultVersionResolver.class ).in( Singleton.class );
51 bind( VersionRangeResolver.class ).to( DefaultVersionRangeResolver.class ).in( Singleton.class );
52 bind( MetadataGeneratorFactory.class ).annotatedWith( Names.named( "snapshot" ) )
53 .to( SnapshotMetadataGeneratorFactory.class ).in( Singleton.class );
54
55 bind( MetadataGeneratorFactory.class ).annotatedWith( Names.named( "versions" ) )
56 .to( VersionsMetadataGeneratorFactory.class ).in( Singleton.class );
57
58 bind( ModelBuilder.class ).toInstance( new DefaultModelBuilderFactory().newInstance() );
59 }
60
61 @Provides
62 @Singleton
63 Set<MetadataGeneratorFactory> provideMetadataGeneratorFactories(
64 @Named( "snapshot" ) MetadataGeneratorFactory snapshot,
65 @Named( "versions" ) MetadataGeneratorFactory versions )
66 {
67 Set<MetadataGeneratorFactory> factories = new HashSet<>( 2 );
68 factories.add( snapshot );
69 factories.add( versions );
70 return Collections.unmodifiableSet( factories );
71 }
72
73 }