From: Edwin L. Punzalan Date: Fri, 24 Feb 2006 06:30:13 +0000 (+0000) Subject: PR: MRM-59 X-Git-Tag: archiva-0.9-alpha-1~909 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c810070fd71f8a7fe0c9030599bf8705a3264c39;p=archiva.git PR: MRM-59 Added basic maven 1.x path parsing to the utils git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@380602 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/maven-repository-utils/src/main/java/org/apache/maven/repository/ArtifactUtils.java b/maven-repository-utils/src/main/java/org/apache/maven/repository/ArtifactUtils.java index b634131f9..a4a9da7cb 100644 --- a/maven-repository-utils/src/main/java/org/apache/maven/repository/ArtifactUtils.java +++ b/maven-repository-utils/src/main/java/org/apache/maven/repository/ArtifactUtils.java @@ -57,9 +57,11 @@ public class ArtifactUtils Collections.reverse( pathParts ); - Artifact finalResult = null; + Artifact artifact = null; if ( pathParts.size() >= 4 ) { + // maven 2.x path + // the actual artifact filename. String filename = (String) pathParts.remove( 0 ); @@ -162,7 +164,7 @@ public class ArtifactUtils } else { - finalResult = result; + artifact = result; } } else if ( !remainingFilename.startsWith( version ) ) @@ -178,18 +180,41 @@ public class ArtifactUtils else { classifier = remainingFilename.substring( version.length() + 1 ); - finalResult = artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, + artifact = artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, type, classifier ); } } else { - finalResult = result; + artifact = result; } } } } + else if ( pathParts.size() == 3 ) + { + //maven 1.x path + + String filename = (String) pathParts.remove( 0 ); + + int idx = filename.lastIndexOf( '-' ); + if ( idx > 0 ) + { + String version = filename.substring( idx + 1 ); + + String artifactId = filename.substring( 0, idx ); + + String types = (String) pathParts.remove( 0 ); + + // remove the "s" in types + String type = types.substring( 0, types.length() -1 ); + + String groupId = (String) pathParts.remove( 0 ); + + artifact = artifactFactory.createArtifact( groupId, artifactId, version, Artifact.SCOPE_RUNTIME, type ); + } + } - return finalResult; + return artifact; } }