This project has retired. For details please refer to its Attic page.
DefaultArtifactMappingProvider xref
View Javadoc
1   package org.apache.archiva.metadata.repository.storage.maven2;
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 org.springframework.stereotype.Service;
23  
24  import java.util.HashMap;
25  import java.util.Map;
26  
27  /**
28   *
29   */
30  @Service( "artifactMappingProvider#default" )
31  public class DefaultArtifactMappingProvider
32      implements ArtifactMappingProvider
33  {
34      private final Map<String, String> classifierAndExtensionToTypeMap;
35  
36      private final Map<String, String> typeToExtensionMap;
37  
38      public DefaultArtifactMappingProvider()
39      {
40          classifierAndExtensionToTypeMap = new HashMap<>( 4 );
41  
42          // Maven 2.2.1 supplied types (excluding defaults where extension == type and no classifier)
43          classifierAndExtensionToTypeMap.put( "client:jar", "ejb-client" );
44          classifierAndExtensionToTypeMap.put( "sources:jar", "java-source" );
45          classifierAndExtensionToTypeMap.put( "javadoc:jar", "javadoc" );
46          classifierAndExtensionToTypeMap.put( "tests:jar", "test-jar" );
47  
48          typeToExtensionMap = new HashMap<>();
49  
50          // Maven 2.2.1 supplied types (excluding defaults where extension == type and no classifier)
51          typeToExtensionMap.put( "ejb-client", "jar" );
52          typeToExtensionMap.put( "ejb", "jar" );
53          typeToExtensionMap.put( "java-source", "jar" );
54          typeToExtensionMap.put( "javadoc", "jar" );
55          typeToExtensionMap.put( "test-jar", "jar" );
56          typeToExtensionMap.put( "maven-plugin", "jar" );
57  
58          // Additional type
59          typeToExtensionMap.put( "maven-archetype", "jar" );
60  
61          // TODO: move to maven 1 plugin - but note that it won't have the interface type and might need to reproduce the
62          //       same thing
63          typeToExtensionMap.put( "maven-one-plugin", "jar" );
64          typeToExtensionMap.put( "javadoc.jar", "jar" );
65          typeToExtensionMap.put( "uberjar", "jar" );
66          typeToExtensionMap.put( "distribution-tgz", "tar.gz" );
67          typeToExtensionMap.put( "distribution-zip", "zip" );
68          typeToExtensionMap.put( "aspect", "jar" );
69      }
70  
71      @Override
72      public String mapClassifierAndExtensionToType( String classifier, String ext )
73      {
74          if ( classifier == null )
75          {
76              classifier = "";
77          }
78          if ( ext == null )
79          {
80              ext = "";
81          }
82          return classifierAndExtensionToTypeMap.get( classifier + ":" + ext );
83      }
84  
85      @Override
86      public String mapTypeToExtension( String type )
87      {
88          return typeToExtensionMap.get( type );
89      }
90  }