View Javadoc
1   package org.apache.maven.repository.internal;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
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  /**
42   * @deprecated As of Maven Resolver 1.0.3, please use class {@link MavenResolverModule}.
43   */
44  @Deprecated
45  public final class MavenAetherModule
46      extends AbstractModule
47  {
48  
49      @Override
50      protected void configure()
51      {
52          install( new AetherModule() );
53          bind( ArtifactDescriptorReader.class ) //
54          .to( DefaultArtifactDescriptorReader.class ).in( Singleton.class );
55          bind( VersionResolver.class ) //
56          .to( DefaultVersionResolver.class ).in( Singleton.class );
57          bind( VersionRangeResolver.class ) //
58          .to( DefaultVersionRangeResolver.class ).in( Singleton.class );
59          bind( MetadataGeneratorFactory.class ).annotatedWith( Names.named( "snapshot" ) ) //
60          .to( SnapshotMetadataGeneratorFactory.class ).in( Singleton.class );
61          bind( MetadataGeneratorFactory.class ).annotatedWith( Names.named( "versions" ) ) //
62          .to( VersionsMetadataGeneratorFactory.class ).in( Singleton.class );
63          bind( ModelBuilder.class ) //
64          .toInstance( new DefaultModelBuilderFactory().newInstance() );
65      }
66  
67      @Provides
68      @Singleton
69      Set<MetadataGeneratorFactory> provideMetadataGeneratorFactories( @Named( "snapshot" )
70                                                                       MetadataGeneratorFactory snapshot,
71                                                                       @Named( "versions" )
72                                                                       MetadataGeneratorFactory versions )
73      {
74          Set<MetadataGeneratorFactory> factories = new HashSet<>();
75          factories.add( snapshot );
76          factories.add( versions );
77          return Collections.unmodifiableSet( factories );
78      }
79  
80  }