]> source.dussan.org Git - archiva.git/commitdiff
remove dependency between archiva-configuration and archiva-model
authorNicolas De Loof <nicolas@apache.org>
Thu, 10 Jan 2008 10:54:32 +0000 (10:54 +0000)
committerNicolas De Loof <nicolas@apache.org>
Thu, 10 Jan 2008 10:54:32 +0000 (10:54 +0000)
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@610753 13f79535-47bb-0310-9956-ffa450edef68

archiva-base/archiva-configuration/pom.xml
archiva-base/archiva-configuration/src/main/mdo/configuration.mdo
archiva-base/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/LegacyArtifactPathTest.java
archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/LegacyPathParser.java

index 14859f4e647ebe417e040b976fc6bafc144e1764..e22b7c84e475a632a0fdf7296650ee44c2f2818a 100644 (file)
       <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>
index 0298c460859a2b963502f309f6b2bc100ad5eaf8..611adff86daf7751240ff282e0d88058ac7a1c47 100644 (file)
         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>
index b2f1bbccdc376ed19303fd2d3f531fdc91f65111..1ad2585d2ba3632ddb6182dbba64f3129f0a48da 100644 (file)
@@ -2,8 +2,6 @@ package org.apache.maven.archiva.configuration;
 \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
@@ -37,12 +35,11 @@ public class LegacyArtifactPathTest
     {\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
@@ -50,11 +47,10 @@ public class LegacyArtifactPathTest
     {\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
index aceef26c1e9f722815004e83e5059ea907d5c8ec..8861b892e652d2bf69fed1ce72aef6b6d4f4255a 100644 (file)
@@ -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, '/' );