]> source.dussan.org Git - archiva.git/commitdiff
PR: MRM-59
authorEdwin L. Punzalan <epunzalan@apache.org>
Fri, 24 Feb 2006 06:30:13 +0000 (06:30 +0000)
committerEdwin L. Punzalan <epunzalan@apache.org>
Fri, 24 Feb 2006 06:30:13 +0000 (06:30 +0000)
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

maven-repository-utils/src/main/java/org/apache/maven/repository/ArtifactUtils.java

index b634131f95255504513311c4de67f51fa0688be6..a4a9da7cb4d3ccf4427e31ec516cab8817a8254a 100644 (file)
@@ -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;
     }
 }