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
This commit is contained in:
Edwin L. Punzalan 2006-02-24 06:30:13 +00:00
parent 8ba07b9513
commit c810070fd7
1 changed files with 30 additions and 5 deletions

View File

@ -57,9 +57,11 @@ public class ArtifactUtils
Collections.reverse( pathParts ); Collections.reverse( pathParts );
Artifact finalResult = null; Artifact artifact = null;
if ( pathParts.size() >= 4 ) if ( pathParts.size() >= 4 )
{ {
// maven 2.x path
// the actual artifact filename. // the actual artifact filename.
String filename = (String) pathParts.remove( 0 ); String filename = (String) pathParts.remove( 0 );
@ -162,7 +164,7 @@ public class ArtifactUtils
} }
else else
{ {
finalResult = result; artifact = result;
} }
} }
else if ( !remainingFilename.startsWith( version ) ) else if ( !remainingFilename.startsWith( version ) )
@ -178,18 +180,41 @@ public class ArtifactUtils
else else
{ {
classifier = remainingFilename.substring( version.length() + 1 ); classifier = remainingFilename.substring( version.length() + 1 );
finalResult = artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, artifact = artifactFactory.createArtifactWithClassifier( groupId, artifactId, version,
type, classifier ); type, classifier );
} }
} }
else 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;
} }
} }