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
26 import javax.inject.Named;
27 import javax.inject.Singleton;
28
29 import org.apache.maven.model.building.DefaultModelBuilderFactory;
30 import org.apache.maven.model.building.ModelBuilder;
31 import org.eclipse.aether.impl.AetherModule;
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
37 import com.google.inject.AbstractModule;
38 import com.google.inject.Provides;
39 import com.google.inject.name.Names;
40
41 public final class MavenAetherModule
42 extends AbstractModule
43 {
44
45 @Override
46 protected void configure()
47 {
48 install( new AetherModule() );
49 bind( ArtifactDescriptorReader.class )
50 .to( DefaultArtifactDescriptorReader.class ).in( Singleton.class );
51 bind( VersionResolver.class )
52 .to( DefaultVersionResolver.class ).in( Singleton.class );
53 bind( VersionRangeResolver.class )
54 .to( DefaultVersionRangeResolver.class ).in( Singleton.class );
55 bind( MetadataGeneratorFactory.class ).annotatedWith( Names.named( "snapshot" ) )
56 .to( SnapshotMetadataGeneratorFactory.class ).in( Singleton.class );
57 bind( MetadataGeneratorFactory.class ).annotatedWith( Names.named( "versions" ) )
58 .to( VersionsMetadataGeneratorFactory.class ).in( Singleton.class );
59 bind( ModelBuilder.class )
60 .toInstance( new DefaultModelBuilderFactory().newInstance() );
61 }
62
63 @Provides
64 @Singleton
65 Set<MetadataGeneratorFactory> provideMetadataGeneratorFactories( @Named( "snapshot" ) MetadataGeneratorFactory snapshot,
66 @Named( "versions" ) MetadataGeneratorFactory versions )
67 {
68 Set<MetadataGeneratorFactory> factories = new HashSet<MetadataGeneratorFactory>();
69 factories.add( snapshot );
70 factories.add( versions );
71 return Collections.unmodifiableSet( factories );
72 }
73
74 }