Author: epunzalan
Date: Thu Feb 23 22:30:13 2006
New Revision: 380602

URL: http://svn.apache.org/viewcvs?rev=380602&view=rev
Log:
PR: MRM-59

Added basic maven 1.x path parsing to the utils

Modified:
    
maven/repository-manager/trunk/maven-repository-utils/src/main/java/org/apache/maven/repository/ArtifactUtils.java

Modified: 
maven/repository-manager/trunk/maven-repository-utils/src/main/java/org/apache/maven/repository/ArtifactUtils.java
URL: 
http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-utils/src/main/java/org/apache/maven/repository/ArtifactUtils.java?rev=380602&r1=380601&r2=380602&view=diff
==============================================================================
--- 
maven/repository-manager/trunk/maven-repository-utils/src/main/java/org/apache/maven/repository/ArtifactUtils.java
 (original)
+++ 
maven/repository-manager/trunk/maven-repository-utils/src/main/java/org/apache/maven/repository/ArtifactUtils.java
 Thu Feb 23 22:30:13 2006
@@ -57,9 +57,11 @@
 
         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 @@
                         }
                         else
                         {
-                            finalResult = result;
+                            artifact = result;
                         }
                     }
                     else if ( !remainingFilename.startsWith( version ) )
@@ -178,18 +180,41 @@
                         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;
     }
 }


Reply via email to