1 package org.apache.maven.archiva.repository.content;
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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
22 import org.apache.archiva.metadata.repository.storage.maven2.ArtifactMappingProvider;
23 import org.apache.archiva.metadata.repository.storage.maven2.DefaultArtifactMappingProvider;
25 import java.util.HashMap;
29 * ArtifactExtensionMapping
33 public class ArtifactExtensionMapping
35 public static final String MAVEN_ARCHETYPE = "maven-archetype";
37 public static final String MAVEN_PLUGIN = "maven-plugin";
39 public static final String MAVEN_ONE_PLUGIN = "maven-one-plugin";
41 private static final Map<String, String> typeToExtensionMap;
43 // TODO: won't support extensions - need to refactor away this class
44 private static final ArtifactMappingProvider mapping = new DefaultArtifactMappingProvider();
48 typeToExtensionMap = new HashMap<String, String>();
49 typeToExtensionMap.put( "ejb-client", "jar" );
50 typeToExtensionMap.put( "ejb", "jar" );
51 typeToExtensionMap.put( "java-source", "jar" );
52 typeToExtensionMap.put( "javadoc", "jar" );
53 typeToExtensionMap.put( "test-jar", "jar" );
54 typeToExtensionMap.put( MAVEN_PLUGIN, "jar" );
56 typeToExtensionMap.put( MAVEN_ARCHETYPE, "jar" );
58 // TODO: move to maven 1 plugin
59 typeToExtensionMap.put( MAVEN_ONE_PLUGIN, "jar" );
60 typeToExtensionMap.put( "javadoc.jar", "jar" );
61 typeToExtensionMap.put( "uberjar", "jar" );
62 typeToExtensionMap.put( "distribution-tgz", "tar.gz" );
63 typeToExtensionMap.put( "distribution-zip", "zip" );
64 typeToExtensionMap.put( "aspect", "jar" );
67 public static String getExtension( String type )
69 // Try specialized types first.
70 if ( typeToExtensionMap.containsKey( type ) )
72 return typeToExtensionMap.get( type );
79 public static String mapExtensionAndClassifierToType( String classifier, String extension )
81 return mapExtensionAndClassifierToType( classifier, extension, extension );
84 public static String mapExtensionAndClassifierToType( String classifier, String extension,
85 String defaultExtension )
87 String value = mapping.mapClassifierAndExtensionToType( classifier, extension );
90 value = mapToMaven1Type( extension );
92 return value != null ? value : defaultExtension;
95 public static String mapExtensionToType( String extension )
97 String value = mapToMaven1Type( extension );
99 return value != null ? value : extension;
102 private static String mapToMaven1Type( String extension )
104 // TODO: Maven 1 plugin
106 if ( "tar.gz".equals( extension ) )
108 value = "distribution-tgz";
110 else if ( "tar.bz2".equals( extension ) )
112 value = "distribution-bzip";
114 else if ( "zip".equals( extension ) )
116 value = "distribution-zip";