From 7d6f2e71223e0fca50b5e0a98e1817814a5aba2b Mon Sep 17 00:00:00 2001 From: Brett Porter Date: Wed, 13 Sep 2006 05:21:12 +0000 Subject: [PATCH] [MRM-163] add support for legacy repo javadoc and source jars Submitted by: nicolas de loof git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@442847 13f79535-47bb-0310-9956-ffa450edef68 --- .../discoverer/LegacyArtifactDiscoverer.java | 10 +++++- .../LegacyArtifactDiscovererTest.java | 31 +++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/archiva-discoverer/src/main/java/org/apache/maven/archiva/discoverer/LegacyArtifactDiscoverer.java b/archiva-discoverer/src/main/java/org/apache/maven/archiva/discoverer/LegacyArtifactDiscoverer.java index 361a6f9a3..6abb95842 100644 --- a/archiva-discoverer/src/main/java/org/apache/maven/archiva/discoverer/LegacyArtifactDiscoverer.java +++ b/archiva-discoverer/src/main/java/org/apache/maven/archiva/discoverer/LegacyArtifactDiscoverer.java @@ -90,6 +90,14 @@ public class LegacyArtifactDiscoverer avceTokenList.addLast( lastAvceToken ); } + else if ( lastAvceToken.endsWith( "javadoc.jar" ) ) + { + type = "javadoc.jar"; + + lastAvceToken = lastAvceToken.substring( 0, lastAvceToken.length() - ".jar".length() ); + + avceTokenList.addLast( lastAvceToken ); + } else if ( lastAvceToken.endsWith( ".zip" ) ) { type = "distribution-zip"; @@ -105,7 +113,7 @@ public class LegacyArtifactDiscoverer if ( extPos > 0 ) { String ext = lastAvceToken.substring( extPos + 1 ); - if ( type.equals( ext ) ) + if ( type.equals( ext ) || "plugin".equals( type ) ) { lastAvceToken = lastAvceToken.substring( 0, extPos ); diff --git a/archiva-discoverer/src/test/java/org/apache/maven/archiva/discoverer/LegacyArtifactDiscovererTest.java b/archiva-discoverer/src/test/java/org/apache/maven/archiva/discoverer/LegacyArtifactDiscovererTest.java index 51b0d8503..9694c87bf 100644 --- a/archiva-discoverer/src/test/java/org/apache/maven/archiva/discoverer/LegacyArtifactDiscovererTest.java +++ b/archiva-discoverer/src/test/java/org/apache/maven/archiva/discoverer/LegacyArtifactDiscovererTest.java @@ -482,6 +482,37 @@ public class LegacyArtifactDiscovererTest assertEquals( createArtifact( "javax.sql", "jdbc", "2.0" ), artifact ); } + public void testJavadoc() + throws ComponentLookupException, DiscovererException + { + String testPath = "javax.sql/javadoc.jars/jdbc-2.0-javadoc.jar"; + + Artifact artifact = discoverer.buildArtifact( testPath ); + + assertEquals( createArtifact( "javax.sql", "jdbc", "2.0", "javadoc.jar", "javadoc" ), artifact ); + } + + public void testSources() + throws ComponentLookupException, DiscovererException + { + String testPath = "javax.sql/java-sources/jdbc-2.0-sources.jar"; + + Artifact artifact = discoverer.buildArtifact( testPath ); + + assertEquals( createArtifact( "javax.sql", "jdbc", "2.0", "java-source", "sources" ), artifact ); + } + + public void testPlugin() + throws ComponentLookupException, DiscovererException + { + String testPath = "maven/plugins/maven-test-plugin-1.8.jar"; + + Artifact artifact = discoverer.buildArtifact( testPath ); + + assertEquals( createArtifact( "maven", "maven-test-plugin", "1.8", "plugin" ), artifact ); + } + + private List discoverArtifacts() throws DiscovererException {