001 package org.apache.archiva.metadata.repository.storage.maven2; 002 003 /* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022 import org.springframework.stereotype.Service; 023 024 import java.util.HashMap; 025 import java.util.Map; 026 027 /** 028 * 029 */ 030 @Service( "artifactMappingProvider#default" ) 031 public class DefaultArtifactMappingProvider 032 implements ArtifactMappingProvider 033 { 034 private final Map<String, String> classifierAndExtensionToTypeMap; 035 036 private final Map<String, String> typeToExtensionMap; 037 038 public DefaultArtifactMappingProvider() 039 { 040 classifierAndExtensionToTypeMap = new HashMap<String, String>(); 041 042 // Maven 2.2.1 supplied types (excluding defaults where extension == type and no classifier) 043 classifierAndExtensionToTypeMap.put( "client:jar", "ejb-client" ); 044 classifierAndExtensionToTypeMap.put( "sources:jar", "java-source" ); 045 classifierAndExtensionToTypeMap.put( "javadoc:jar", "javadoc" ); 046 classifierAndExtensionToTypeMap.put( "tests:jar", "test-jar" ); 047 048 typeToExtensionMap = new HashMap<String, String>(); 049 050 // Maven 2.2.1 supplied types (excluding defaults where extension == type and no classifier) 051 typeToExtensionMap.put( "ejb-client", "jar" ); 052 typeToExtensionMap.put( "ejb", "jar" ); 053 typeToExtensionMap.put( "java-source", "jar" ); 054 typeToExtensionMap.put( "javadoc", "jar" ); 055 typeToExtensionMap.put( "test-jar", "jar" ); 056 typeToExtensionMap.put( "maven-plugin", "jar" ); 057 058 // Additional type 059 typeToExtensionMap.put( "maven-archetype", "jar" ); 060 061 // TODO: move to maven 1 plugin - but note that it won't have the interface type and might need to reproduce the 062 // same thing 063 typeToExtensionMap.put( "maven-one-plugin", "jar" ); 064 typeToExtensionMap.put( "javadoc.jar", "jar" ); 065 typeToExtensionMap.put( "uberjar", "jar" ); 066 typeToExtensionMap.put( "distribution-tgz", "tar.gz" ); 067 typeToExtensionMap.put( "distribution-zip", "zip" ); 068 typeToExtensionMap.put( "aspect", "jar" ); 069 } 070 071 public String mapClassifierAndExtensionToType( String classifier, String ext ) 072 { 073 if ( classifier == null ) 074 { 075 classifier = ""; 076 } 077 if ( ext == null ) 078 { 079 ext = ""; 080 } 081 return classifierAndExtensionToTypeMap.get( classifier + ":" + ext ); 082 } 083 084 public String mapTypeToExtension( String type ) 085 { 086 return typeToExtensionMap.get( type ); 087 } 088 }