git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@610753 13f79535-47bb-0310-9956-ffa450edef68tags/archiva-1.0.1
@@ -36,10 +36,6 @@ | |||
<groupId>org.apache.maven.archiva</groupId> | |||
<artifactId>archiva-policies</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.apache.maven.archiva</groupId> | |||
<artifactId>archiva-model</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.codehaus.plexus</groupId> | |||
<artifactId>plexus-component-api</artifactId> |
@@ -473,19 +473,30 @@ | |||
return path.equals( this.path ); | |||
} | |||
public org.apache.maven.archiva.model.ArtifactReference getArtifactReference() | |||
public String getGroupId() | |||
{ | |||
org.apache.maven.archiva.model.ArtifactReference reference = new org.apache.maven.archiva.model.ArtifactReference(); | |||
String[] parts = artifact.split( ":" ); | |||
reference.setGroupId( parts[0] ); | |||
reference.setArtifactId( parts[1] ); | |||
reference.setVersion( parts[2] ); | |||
if ( parts[3].length() > 0 ) | |||
{ | |||
reference.setClassifier( parts[3] ); | |||
} | |||
reference.setType( parts[4] ); | |||
return reference; | |||
return artifact.split( ":" )[0]; | |||
} | |||
public String getArtifactId() | |||
{ | |||
return artifact.split( ":" )[1]; | |||
} | |||
public String getVersion() | |||
{ | |||
return artifact.split( ":" )[2]; | |||
} | |||
public String getClassifier() | |||
{ | |||
String classifier = artifact.split( ":" )[3]; | |||
return classifier.length() > 0 ? classifier : null; | |||
} | |||
public String getType() | |||
{ | |||
return artifact.split( ":" )[4]; | |||
} | |||
]]></code> | |||
</codeSegment> |
@@ -2,8 +2,6 @@ package org.apache.maven.archiva.configuration; | |||
import junit.framework.TestCase; | |||
import org.apache.maven.archiva.model.ArtifactReference; | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one | |||
* or more contributor license agreements. See the NOTICE file | |||
@@ -37,12 +35,11 @@ public class LegacyArtifactPathTest | |||
{ | |||
legacyArtifactPath.setArtifact( "groupId:artifactId:version:classifier:type" ); | |||
ArtifactReference artifact = legacyArtifactPath.getArtifactReference(); | |||
assertEquals( "groupId", artifact.getGroupId() ); | |||
assertEquals( "artifactId", artifact.getArtifactId() ); | |||
assertEquals( "version", artifact.getVersion() ); | |||
assertEquals( "classifier", artifact.getClassifier() ); | |||
assertEquals( "type", artifact.getType() ); | |||
assertEquals( "groupId", legacyArtifactPath.getGroupId() ); | |||
assertEquals( "artifactId", legacyArtifactPath.getArtifactId() ); | |||
assertEquals( "version", legacyArtifactPath.getVersion() ); | |||
assertEquals( "classifier", legacyArtifactPath.getClassifier() ); | |||
assertEquals( "type", legacyArtifactPath.getType() ); | |||
} | |||
@@ -50,11 +47,10 @@ public class LegacyArtifactPathTest | |||
{ | |||
legacyArtifactPath.setArtifact( "groupId:artifactId:version::type" ); | |||
ArtifactReference artifact = legacyArtifactPath.getArtifactReference(); | |||
assertEquals( "groupId", artifact.getGroupId() ); | |||
assertEquals( "artifactId", artifact.getArtifactId() ); | |||
assertEquals( "version", artifact.getVersion() ); | |||
assertEquals( null, artifact.getClassifier() ); | |||
assertEquals( "type", artifact.getType() ); | |||
assertEquals( "groupId", legacyArtifactPath.getGroupId() ); | |||
assertEquals( "artifactId", legacyArtifactPath.getArtifactId() ); | |||
assertEquals( "version", legacyArtifactPath.getVersion() ); | |||
assertNull( legacyArtifactPath.getClassifier() ); | |||
assertEquals( "type", legacyArtifactPath.getType() ); | |||
} | |||
} |
@@ -56,19 +56,24 @@ public class LegacyPathParser | |||
public ArtifactReference toArtifactReference( String path ) | |||
throws LayoutException | |||
{ | |||
ArtifactReference artifact = new ArtifactReference(); | |||
// First, look if a custom resolution rule has been set for this artifact | |||
Collection legacy = configuration.getConfiguration().getLegacyArtifactPaths(); | |||
for ( Iterator iterator = legacy.iterator(); iterator.hasNext(); ) | |||
{ | |||
LegacyArtifactPath legacyPath = (LegacyArtifactPath) iterator.next(); | |||
if ( legacyPath.match( path ) ) | |||
{ | |||
return legacyPath.getArtifactReference(); | |||
{ | |||
artifact.setGroupId( legacyPath.getGroupId() ); | |||
artifact.setArtifactId( legacyPath.getArtifactId() ); | |||
artifact.setClassifier( legacyPath.getClassifier() ); | |||
artifact.setVersion( legacyPath.getVersion() ); | |||
artifact.setType( legacyPath.getType() ); | |||
return artifact; | |||
} | |||
} | |||
ArtifactReference artifact = new ArtifactReference(); | |||
String normalizedPath = StringUtils.replace( path, "\\", "/" ); | |||
String pathParts[] = StringUtils.split( normalizedPath, '/' ); |