aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrett Porter <brett@apache.org>2010-03-10 04:02:48 +0000
committerBrett Porter <brett@apache.org>2010-03-10 04:02:48 +0000
commit780176f7f54e33b1f1b0663248fc273c1236ccf9 (patch)
tree4fa772258a33a6cc7b83e149495f5cc9060f10e9
parent989f143a5f0bd91d94fd85eb7f44293344feed6f (diff)
downloadarchiva-780176f7f54e33b1f1b0663248fc273c1236ccf9.tar.gz
archiva-780176f7f54e33b1f1b0663248fc273c1236ccf9.zip
[MRM-1360] move type population into Maven 2 plugin
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@921224 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/ArtifactExtensionMapping.java51
-rw-r--r--archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/maven-metadata.xml6
-rw-r--r--archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/maven-metadata.xml.md52
-rw-r--r--archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/maven-metadata.xml.sha12
-rw-r--r--archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100310.014828-2-javadoc.jarbin0 -> 20221 bytes
-rw-r--r--archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100310.014828-2-javadoc.jar.md51
-rw-r--r--archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100310.014828-2-javadoc.jar.sha11
-rw-r--r--archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100310.014828-2-sources.jarbin0 -> 637 bytes
-rw-r--r--archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100310.014828-2-sources.jar.md51
-rw-r--r--archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100310.014828-2-sources.jar.sha11
-rw-r--r--archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100310.014828-2.jarbin0 -> 2124 bytes
-rw-r--r--archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100310.014828-2.jar.md51
-rw-r--r--archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100310.014828-2.jar.sha11
-rw-r--r--archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100310.014828-2.pom24
-rw-r--r--archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100310.014828-2.pom.md51
-rw-r--r--archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100310.014828-2.pom.sha11
-rw-r--r--archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/maven-metadata.xml3
-rw-r--r--archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/maven-metadata.xml.md52
-rw-r--r--archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/maven-metadata.xml.sha12
-rw-r--r--archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/ArtifactMappingProvider.java25
-rw-r--r--archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/DefaultArtifactMappingProvider.java50
-rw-r--r--archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryPathTranslator.java45
-rw-r--r--archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverTest.java75
23 files changed, 250 insertions, 45 deletions
diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/ArtifactExtensionMapping.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/ArtifactExtensionMapping.java
index d4f70fb8f..6f235cc76 100644
--- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/ArtifactExtensionMapping.java
+++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/ArtifactExtensionMapping.java
@@ -19,6 +19,9 @@ package org.apache.maven.archiva.repository.content;
* under the License.
*/
+import org.apache.archiva.metadata.repository.storage.maven2.ArtifactMappingProvider;
+import org.apache.archiva.metadata.repository.storage.maven2.DefaultArtifactMappingProvider;
+
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Pattern;
@@ -40,21 +43,28 @@ public class ArtifactExtensionMapping
private static final Pattern mavenPluginPattern = Pattern.compile( "^(maven-.*-plugin)|(.*-maven-plugin)$" );
+ // TODO: won't support extensions - need to refactor away this class
+ private static final ArtifactMappingProvider mapping = new DefaultArtifactMappingProvider();
+
static
{
typeToExtensionMap = new HashMap<String, String>();
typeToExtensionMap.put( "ejb-client", "jar" );
typeToExtensionMap.put( "ejb", "jar" );
- typeToExtensionMap.put( "distribution-tgz", "tar.gz" );
- typeToExtensionMap.put( "distribution-zip", "zip" );
typeToExtensionMap.put( "java-source", "jar" );
- typeToExtensionMap.put( "javadoc.jar", "jar" );
typeToExtensionMap.put( "javadoc", "jar" );
- typeToExtensionMap.put( "aspect", "jar" );
- typeToExtensionMap.put( "uberjar", "jar" );
+ typeToExtensionMap.put( "test-jar", "jar" );
typeToExtensionMap.put( MAVEN_PLUGIN, "jar" );
- typeToExtensionMap.put( MAVEN_ONE_PLUGIN, "jar" );
+
typeToExtensionMap.put( MAVEN_ARCHETYPE, "jar" );
+
+ // TODO: move to maven 1 plugin
+ typeToExtensionMap.put( MAVEN_ONE_PLUGIN, "jar" );
+ typeToExtensionMap.put( "javadoc.jar", "jar" );
+ typeToExtensionMap.put( "uberjar", "jar" );
+ typeToExtensionMap.put( "distribution-tgz", "tar.gz" );
+ typeToExtensionMap.put( "distribution-zip", "zip" );
+ typeToExtensionMap.put( "aspect", "jar" );
}
public static String getExtension( String type )
@@ -62,7 +72,7 @@ public class ArtifactExtensionMapping
// Try specialized types first.
if ( typeToExtensionMap.containsKey( type ) )
{
- return (String) typeToExtensionMap.get( type );
+ return typeToExtensionMap.get( type );
}
// Return type
@@ -88,36 +98,37 @@ public class ArtifactExtensionMapping
public static String mapExtensionAndClassifierToType( String classifier, String extension,
String defaultExtension )
{
- if ( "sources".equals( classifier ) )
- {
- return "java-source";
- }
- else if ( "javadoc".equals( classifier ) )
+ String value = mapping.mapClassifierAndExtensionToType( classifier, extension );
+ if ( value == null )
{
- return "javadoc";
+ value = mapToMaven1Type( extension );
}
- return mapExtensionToType( extension, defaultExtension );
+ return value != null ? value : defaultExtension;
}
public static String mapExtensionToType( String extension )
{
- return mapExtensionToType( extension, extension );
+ String value = mapToMaven1Type( extension );
+
+ return value != null ? value : extension;
}
- private static String mapExtensionToType( String extension, String defaultExtension )
+ private static String mapToMaven1Type( String extension )
{
+ // TODO: Maven 1 plugin
+ String value = null;
if ( "tar.gz".equals( extension ) )
{
- return "distribution-tgz";
+ value = "distribution-tgz";
}
else if ( "tar.bz2".equals( extension ) )
{
- return "distribution-bzip";
+ value = "distribution-bzip";
}
else if ( "zip".equals( extension ) )
{
- return "distribution-zip";
+ value = "distribution-zip";
}
- return defaultExtension;
+ return value;
}
}
diff --git a/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/maven-metadata.xml b/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/maven-metadata.xml
index 89f58d525..dee64e3fe 100644
--- a/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/maven-metadata.xml
+++ b/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/maven-metadata.xml
@@ -5,9 +5,9 @@
<version>1.0-SNAPSHOT</version>
<versioning>
<snapshot>
- <timestamp>20100308.230825</timestamp>
- <buildNumber>1</buildNumber>
+ <timestamp>20100310.014828</timestamp>
+ <buildNumber>2</buildNumber>
</snapshot>
- <lastUpdated>20100308230825</lastUpdated>
+ <lastUpdated>20100310014828</lastUpdated>
</versioning>
</metadata>
diff --git a/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/maven-metadata.xml.md5 b/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/maven-metadata.xml.md5
index d774a5365..4ce347dc1 100644
--- a/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/maven-metadata.xml.md5
+++ b/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/maven-metadata.xml.md5
@@ -1 +1 @@
-7210867ac16cd955db89cfca699e7c96 \ No newline at end of file
+aad6835e3e7a4a9de5318ce9183eab54 \ No newline at end of file
diff --git a/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/maven-metadata.xml.sha1 b/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/maven-metadata.xml.sha1
index 0e44079af..9318aa84b 100644
--- a/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/maven-metadata.xml.sha1
+++ b/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/maven-metadata.xml.sha1
@@ -1 +1 @@
-271faeb2039d026ee6a3c937375b5ff7d4b1d605 \ No newline at end of file
+73669371dc2fdae2fa9a129932ed0932d62d9e6b \ No newline at end of file
diff --git a/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100310.014828-2-javadoc.jar b/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100310.014828-2-javadoc.jar
new file mode 100644
index 000000000..5aab069ab
--- /dev/null
+++ b/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100310.014828-2-javadoc.jar
Binary files differ
diff --git a/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100310.014828-2-javadoc.jar.md5 b/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100310.014828-2-javadoc.jar.md5
new file mode 100644
index 000000000..f6be27c2b
--- /dev/null
+++ b/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100310.014828-2-javadoc.jar.md5
@@ -0,0 +1 @@
+e034e44b0d9f3968ebfbc66c71b41ba0 \ No newline at end of file
diff --git a/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100310.014828-2-javadoc.jar.sha1 b/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100310.014828-2-javadoc.jar.sha1
new file mode 100644
index 000000000..56fd634ce
--- /dev/null
+++ b/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100310.014828-2-javadoc.jar.sha1
@@ -0,0 +1 @@
+ca8d1408b05d125d0307dbd23063e5aa04235d35 \ No newline at end of file
diff --git a/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100310.014828-2-sources.jar b/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100310.014828-2-sources.jar
new file mode 100644
index 000000000..4863d8aa3
--- /dev/null
+++ b/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100310.014828-2-sources.jar
Binary files differ
diff --git a/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100310.014828-2-sources.jar.md5 b/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100310.014828-2-sources.jar.md5
new file mode 100644
index 000000000..35b216fdb
--- /dev/null
+++ b/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100310.014828-2-sources.jar.md5
@@ -0,0 +1 @@
+a47f0edab0271fc55a3db38098f5f78a \ No newline at end of file
diff --git a/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100310.014828-2-sources.jar.sha1 b/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100310.014828-2-sources.jar.sha1
new file mode 100644
index 000000000..818b1e1df
--- /dev/null
+++ b/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100310.014828-2-sources.jar.sha1
@@ -0,0 +1 @@
+af4c914ef8f80be2a8241fb4d40cff11f4348c0f \ No newline at end of file
diff --git a/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100310.014828-2.jar b/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100310.014828-2.jar
new file mode 100644
index 000000000..3176aff71
--- /dev/null
+++ b/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100310.014828-2.jar
Binary files differ
diff --git a/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100310.014828-2.jar.md5 b/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100310.014828-2.jar.md5
new file mode 100644
index 000000000..3a6bb7df7
--- /dev/null
+++ b/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100310.014828-2.jar.md5
@@ -0,0 +1 @@
+37786de9e272ed6db8541855e0e2d5dc \ No newline at end of file
diff --git a/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100310.014828-2.jar.sha1 b/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100310.014828-2.jar.sha1
new file mode 100644
index 000000000..0e08bb630
--- /dev/null
+++ b/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100310.014828-2.jar.sha1
@@ -0,0 +1 @@
+bb1ca7834422926d0cb79ef303b715bc17f41661 \ No newline at end of file
diff --git a/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100310.014828-2.pom b/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100310.014828-2.pom
new file mode 100644
index 000000000..65ed8cf24
--- /dev/null
+++ b/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100310.014828-2.pom
@@ -0,0 +1,24 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>com.example.test</groupId>
+ <artifactId>test-artifact</artifactId>
+ <packaging>jar</packaging>
+ <version>1.0-SNAPSHOT</version>
+ <name>test-artifact</name>
+ <url>http://maven.apache.org</url>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <distributionManagement>
+ <repository>
+ <id>test</id>
+ <url>file:${basedir}/repository</url>
+ </repository>
+ </distributionManagement>
+</project>
diff --git a/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100310.014828-2.pom.md5 b/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100310.014828-2.pom.md5
new file mode 100644
index 000000000..78a9c2695
--- /dev/null
+++ b/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100310.014828-2.pom.md5
@@ -0,0 +1 @@
+0612c49b1ac80983bfda08616330a4b8 \ No newline at end of file
diff --git a/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100310.014828-2.pom.sha1 b/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100310.014828-2.pom.sha1
new file mode 100644
index 000000000..f2385b6e2
--- /dev/null
+++ b/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100310.014828-2.pom.sha1
@@ -0,0 +1 @@
+156d6062060743bf28df306e067914d3d692b571 \ No newline at end of file
diff --git a/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/maven-metadata.xml b/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/maven-metadata.xml
index 2678fa1dc..2eee6af0d 100644
--- a/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/maven-metadata.xml
+++ b/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/maven-metadata.xml
@@ -4,9 +4,10 @@
<artifactId>test-artifact</artifactId>
<version>1.0-SNAPSHOT</version>
<versioning>
+ <release>1.0-SNAPSHOT</release>
<versions>
<version>1.0-SNAPSHOT</version>
</versions>
- <lastUpdated>20100308230825</lastUpdated>
+ <lastUpdated>20100310014828</lastUpdated>
</versioning>
</metadata>
diff --git a/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/maven-metadata.xml.md5 b/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/maven-metadata.xml.md5
index 3dff69b48..c92cd8c2d 100644
--- a/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/maven-metadata.xml.md5
+++ b/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/maven-metadata.xml.md5
@@ -1 +1 @@
-93afaac7340faadc7efd097952d79fa4 \ No newline at end of file
+4c0a7072d66cfe2deebd3eb998332ccb \ No newline at end of file
diff --git a/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/maven-metadata.xml.sha1 b/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/maven-metadata.xml.sha1
index 1ff7fb544..5835051b4 100644
--- a/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/maven-metadata.xml.sha1
+++ b/archiva-modules/metadata/test-repository/src/main/resources/com/example/test/test-artifact/maven-metadata.xml.sha1
@@ -1 +1 @@
-d59d588343d61fd7d838984a0daa4aaa2546bf9d \ No newline at end of file
+64c28127c4923ff352021bdfdad448d2d881ef3b \ No newline at end of file
diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/ArtifactMappingProvider.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/ArtifactMappingProvider.java
new file mode 100644
index 000000000..b53bbdc19
--- /dev/null
+++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/ArtifactMappingProvider.java
@@ -0,0 +1,25 @@
+package org.apache.archiva.metadata.repository.storage.maven2;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+public interface ArtifactMappingProvider
+{
+ String mapClassifierAndExtensionToType( String classifier, String ext );
+}
diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/DefaultArtifactMappingProvider.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/DefaultArtifactMappingProvider.java
new file mode 100644
index 000000000..88048e9b8
--- /dev/null
+++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/DefaultArtifactMappingProvider.java
@@ -0,0 +1,50 @@
+package org.apache.archiva.metadata.repository.storage.maven2;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @plexus.component role="org.apache.archiva.metadata.repository.storage.maven2.ArtifactMappingProvider" role-hint="default"
+ */
+public class DefaultArtifactMappingProvider
+ implements ArtifactMappingProvider
+{
+ private final Map<String,String> classifierAndExtensionToTypeMap;
+
+ public DefaultArtifactMappingProvider()
+ {
+ classifierAndExtensionToTypeMap = new HashMap<String,String>();
+
+ // Maven 2.2.1 supplied types (excluding defaults where extension == type and no classifier)
+ classifierAndExtensionToTypeMap.put( "client:jar", "ejb-client" );
+ classifierAndExtensionToTypeMap.put( "sources:jar", "java-source" );
+ classifierAndExtensionToTypeMap.put( "javadoc:jar", "javadoc" );
+ classifierAndExtensionToTypeMap.put( "tests:jar", "test-jar" );
+ }
+
+ public String mapClassifierAndExtensionToType( String classifier, String ext )
+ {
+ classifier = classifier != null ? classifier : "";
+ ext = ext != null ? ext : "";
+ return classifierAndExtensionToTypeMap.get( classifier + ":" + ext );
+ }
+}
diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryPathTranslator.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryPathTranslator.java
index e96fabfa3..2ff02478f 100644
--- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryPathTranslator.java
+++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryPathTranslator.java
@@ -1,13 +1,5 @@
package org.apache.archiva.metadata.repository.storage.maven2;
-import org.apache.archiva.metadata.model.ArtifactMetadata;
-import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator;
-import org.apache.maven.archiva.common.utils.VersionUtil;
-
-import java.io.File;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -27,6 +19,15 @@ import java.util.regex.Pattern;
* under the License.
*/
+import org.apache.archiva.metadata.model.ArtifactMetadata;
+import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator;
+import org.apache.maven.archiva.common.utils.VersionUtil;
+
+import java.io.File;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
/**
* @plexus.component role="org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator" role-hint="maven2"
*/
@@ -39,6 +40,11 @@ public class Maven2RepositoryPathTranslator
private static final Pattern TIMESTAMP_PATTERN = Pattern.compile( "([0-9]{8}.[0-9]{6})-([0-9]+).*" );
+ /**
+ * @plexus.requirement role="org.apache.archiva.metadata.repository.storage.maven2.ArtifactMappingProvider"
+ */
+ private List<ArtifactMappingProvider> artifactMappingProviders;
+
public File toFile( File basedir, String namespace, String projectId, String projectVersion, String filename )
{
return new File( basedir, toPath( namespace, projectId, projectVersion, filename ) );
@@ -180,6 +186,8 @@ public class Maven2RepositoryPathTranslator
m.matches();
String timestamp = m.group( 1 );
String buildNumber = m.group( 2 );
+ facet.setTimestamp( timestamp );
+ facet.setBuildNumber( Integer.valueOf( buildNumber ) );
version = idSubStrFromVersion.substring( 0, mainVersionLength ) + timestamp + "-" + buildNumber;
}
catch ( IllegalStateException e )
@@ -246,8 +254,25 @@ public class Maven2RepositoryPathTranslator
metadata.setVersion( version );
facet.setClassifier( classifier );
- // TODO: migrate here from ArtifactExtensionMapping and make extensible
-// facet.setType( );
+
+ // we use our own provider here instead of directly accessing Maven's artifact handlers as it has no way
+ // to select the correct order to apply multiple extensions mappings to a preferred type
+ // TODO: this won't allow the user to decide order to apply them if there are conflicts or desired changes -
+ // perhaps the plugins could register missing entries in configuration, then we just use configuration
+ // here?
+
+ String type = null;
+ for ( ArtifactMappingProvider mapping : artifactMappingProviders )
+ {
+ type = mapping.mapClassifierAndExtensionToType( classifier, ext );
+ if ( type != null )
+ {
+ break;
+ }
+ }
+
+ // use extension as default
+ facet.setType( type != null ? type : ext );
metadata.addFacet( facet );
return metadata;
diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverTest.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverTest.java
index b8580eaac..1084bc0f7 100644
--- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverTest.java
+++ b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverTest.java
@@ -133,7 +133,6 @@ public class Maven2RepositoryMetadataResolverTest
assertDependency( dependencies.get( 9 ), "easymock", "easymockclassextension", "1.2", "test" );
}
- // TODO: test snapshot, rest of artifacts
public void testGetArtifactMetadata()
throws Exception
{
@@ -156,8 +155,7 @@ public class Maven2RepositoryMetadataResolverTest
assertEquals( 0, facet.getBuildNumber() );
assertNull( facet.getTimestamp() );
assertEquals( "sources", facet.getClassifier() );
- // TODO
-// assertEquals( "java-source", facet.getType() );
+ assertEquals( "java-source", facet.getType() );
artifactMetadata = artifacts.get( 1 );
assertEquals( "plexus-spring-1.2.jar", artifactMetadata.getId() );
@@ -165,8 +163,7 @@ public class Maven2RepositoryMetadataResolverTest
assertEquals( 0, facet.getBuildNumber() );
assertNull( facet.getTimestamp() );
assertNull( facet.getClassifier() );
- // TODO
-// assertEquals( "jar", facet.getType() );
+ assertEquals( "jar", facet.getType() );
artifactMetadata = artifacts.get( 2 );
assertEquals( "plexus-spring-1.2.pom", artifactMetadata.getId() );
@@ -174,8 +171,72 @@ public class Maven2RepositoryMetadataResolverTest
assertEquals( 0, facet.getBuildNumber() );
assertNull( facet.getTimestamp() );
assertNull( facet.getClassifier() );
- // TODO
-// assertEquals( "pom", facet.getType() );
+ assertEquals( "pom", facet.getType() );
+ }
+
+ public void testGetArtifactMetadataSnapshots()
+ throws Exception
+ {
+ Collection<ArtifactMetadata> testArtifacts = resolver.getArtifacts( TEST_REPO_ID, "com.example.test",
+ "test-artifact", "1.0-SNAPSHOT" );
+ List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>( testArtifacts );
+ Collections.sort( artifacts, new Comparator<ArtifactMetadata>()
+ {
+ public int compare( ArtifactMetadata o1, ArtifactMetadata o2 )
+ {
+ return o1.getId().compareTo( o2.getId() );
+ }
+ } );
+
+ assertEquals( 6, artifacts.size() );
+
+ ArtifactMetadata artifactMetadata = artifacts.get( 0 );
+ assertEquals( "test-artifact-1.0-20100308.230825-1.jar", artifactMetadata.getId() );
+ MavenArtifactFacet facet = (MavenArtifactFacet) artifactMetadata.getFacet( MavenArtifactFacet.FACET_ID );
+ assertEquals( 1, facet.getBuildNumber() );
+ assertEquals( "20100308.230825", facet.getTimestamp() );
+ assertNull( facet.getClassifier() );
+ assertEquals( "jar", facet.getType() );
+
+ artifactMetadata = artifacts.get( 1 );
+ assertEquals( "test-artifact-1.0-20100308.230825-1.pom", artifactMetadata.getId() );
+ facet = (MavenArtifactFacet) artifactMetadata.getFacet( MavenArtifactFacet.FACET_ID );
+ assertEquals( 1, facet.getBuildNumber() );
+ assertEquals( "20100308.230825", facet.getTimestamp() );
+ assertNull( facet.getClassifier() );
+ assertEquals( "pom", facet.getType() );
+
+ artifactMetadata = artifacts.get( 2 );
+ assertEquals( "test-artifact-1.0-20100310.014828-2-javadoc.jar", artifactMetadata.getId() );
+ facet = (MavenArtifactFacet) artifactMetadata.getFacet( MavenArtifactFacet.FACET_ID );
+ assertEquals( 2, facet.getBuildNumber() );
+ assertEquals( "20100310.014828", facet.getTimestamp() );
+ assertEquals( "javadoc", facet.getClassifier() );
+ assertEquals( "javadoc", facet.getType() );
+
+ artifactMetadata = artifacts.get( 3 );
+ assertEquals( "test-artifact-1.0-20100310.014828-2-sources.jar", artifactMetadata.getId() );
+ facet = (MavenArtifactFacet) artifactMetadata.getFacet( MavenArtifactFacet.FACET_ID );
+ assertEquals( 2, facet.getBuildNumber() );
+ assertEquals( "20100310.014828", facet.getTimestamp() );
+ assertEquals( "sources", facet.getClassifier() );
+ assertEquals( "java-source", facet.getType() );
+
+ artifactMetadata = artifacts.get( 4 );
+ assertEquals( "test-artifact-1.0-20100310.014828-2.jar", artifactMetadata.getId() );
+ facet = (MavenArtifactFacet) artifactMetadata.getFacet( MavenArtifactFacet.FACET_ID );
+ assertEquals( 2, facet.getBuildNumber() );
+ assertEquals( "20100310.014828", facet.getTimestamp() );
+ assertNull( facet.getClassifier() );
+ assertEquals( "jar", facet.getType() );
+
+ artifactMetadata = artifacts.get( 5 );
+ assertEquals( "test-artifact-1.0-20100310.014828-2.pom", artifactMetadata.getId() );
+ facet = (MavenArtifactFacet) artifactMetadata.getFacet( MavenArtifactFacet.FACET_ID );
+ assertEquals( 2, facet.getBuildNumber() );
+ assertEquals( "20100310.014828", facet.getTimestamp() );
+ assertNull( facet.getClassifier() );
+ assertEquals( "pom", facet.getType() );
}
private void assertDependency( Dependency dependency, String groupId, String artifactId, String version )