<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>
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>
\r
import junit.framework.TestCase;\r
\r
-import org.apache.maven.archiva.model.ArtifactReference;\r
-\r
/*\r
* Licensed to the Apache Software Foundation (ASF) under one\r
* or more contributor license agreements. See the NOTICE file\r
{\r
legacyArtifactPath.setArtifact( "groupId:artifactId:version:classifier:type" );\r
\r
- ArtifactReference artifact = legacyArtifactPath.getArtifactReference();\r
- assertEquals( "groupId", artifact.getGroupId() );\r
- assertEquals( "artifactId", artifact.getArtifactId() );\r
- assertEquals( "version", artifact.getVersion() );\r
- assertEquals( "classifier", artifact.getClassifier() );\r
- assertEquals( "type", artifact.getType() );\r
+ assertEquals( "groupId", legacyArtifactPath.getGroupId() );\r
+ assertEquals( "artifactId", legacyArtifactPath.getArtifactId() );\r
+ assertEquals( "version", legacyArtifactPath.getVersion() );\r
+ assertEquals( "classifier", legacyArtifactPath.getClassifier() );\r
+ assertEquals( "type", legacyArtifactPath.getType() );\r
}\r
\r
\r
{\r
legacyArtifactPath.setArtifact( "groupId:artifactId:version::type" );\r
\r
- ArtifactReference artifact = legacyArtifactPath.getArtifactReference();\r
- assertEquals( "groupId", artifact.getGroupId() );\r
- assertEquals( "artifactId", artifact.getArtifactId() );\r
- assertEquals( "version", artifact.getVersion() );\r
- assertEquals( null, artifact.getClassifier() );\r
- assertEquals( "type", artifact.getType() );\r
+ assertEquals( "groupId", legacyArtifactPath.getGroupId() );\r
+ assertEquals( "artifactId", legacyArtifactPath.getArtifactId() );\r
+ assertEquals( "version", legacyArtifactPath.getVersion() );\r
+ assertNull( legacyArtifactPath.getClassifier() );\r
+ assertEquals( "type", legacyArtifactPath.getType() );\r
}\r
}\r
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, '/' );