1package org.apache.archiva.metadata.repository.storage.maven2;
23/*4 * Licensed to the Apache Software Foundation (ASF) under one5 * or more contributor license agreements. See the NOTICE file6 * distributed with this work for additional information7 * regarding copyright ownership. The ASF licenses this file8 * to you under the Apache License, Version 2.0 (the9 * "License"); you may not use this file except in compliance10 * with the License. You may obtain a copy of the License at11 *12 * http://www.apache.org/licenses/LICENSE-2.013 *14 * Unless required by applicable law or agreed to in writing,15 * software distributed under the License is distributed on an16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY17 * KIND, either express or implied. See the License for the18 * specific language governing permissions and limitations19 * under the License.20 */2122import org.springframework.stereotype.Service;
2324import java.util.HashMap;
25import java.util.Map;
2627/**28 *29 */30 @Service( "artifactMappingProvider#default" )
31publicclassDefaultArtifactMappingProvider32implementsArtifactMappingProvider33 {
34privatefinal Map<String, String> classifierAndExtensionToTypeMap;
3536privatefinal Map<String, String> typeToExtensionMap;
3738publicDefaultArtifactMappingProvider()
39 {
40 classifierAndExtensionToTypeMap = new HashMap<>( 4 );
4142// 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" );
4748 typeToExtensionMap = new HashMap<>();
4950// 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" );
5758// Additional type59 typeToExtensionMap.put( "maven-archetype", "jar" );
6061// TODO: move to maven 1 plugin - but note that it won't have the interface type and might need to reproduce the62// same thing63 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 }
7071 @Override
72public String mapClassifierAndExtensionToType( String classifier, String ext )
73 {
74if ( classifier == null )
75 {
76 classifier = "";
77 }
78if ( ext == null )
79 {
80 ext = "";
81 }
82return classifierAndExtensionToTypeMap.get( classifier + ":" + ext );
83 }
8485 @Override
86public String mapTypeToExtension( String type )
87 {
88return typeToExtensionMap.get( type );
89 }
90 }