From: Nicolas De Loof Date: Thu, 10 Jan 2008 10:54:32 +0000 (+0000) Subject: remove dependency between archiva-configuration and archiva-model X-Git-Tag: archiva-1.0.1~22 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=75a2efd2dd80edfa249a49e031f428f437357707;p=archiva.git remove dependency between archiva-configuration and archiva-model git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@610753 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-base/archiva-configuration/pom.xml b/archiva-base/archiva-configuration/pom.xml index 14859f4e6..e22b7c84e 100644 --- a/archiva-base/archiva-configuration/pom.xml +++ b/archiva-base/archiva-configuration/pom.xml @@ -36,10 +36,6 @@ org.apache.maven.archiva archiva-policies - - org.apache.maven.archiva - archiva-model - org.codehaus.plexus plexus-component-api diff --git a/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo b/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo index 0298c4608..611adff86 100644 --- a/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo +++ b/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo @@ -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]; } ]]> diff --git a/archiva-base/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/LegacyArtifactPathTest.java b/archiva-base/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/LegacyArtifactPathTest.java index b2f1bbccd..1ad2585d2 100644 --- a/archiva-base/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/LegacyArtifactPathTest.java +++ b/archiva-base/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/LegacyArtifactPathTest.java @@ -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() ); } } diff --git a/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/LegacyPathParser.java b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/LegacyPathParser.java index aceef26c1..8861b892e 100644 --- a/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/LegacyPathParser.java +++ b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/LegacyPathParser.java @@ -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, '/' );