You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by og...@apache.org on 2009/01/22 06:36:03 UTC

svn commit: r736568 - in /maven/mercury/trunk/mercury-repo: mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/ mercury-repo-local-m2/src/test/java/org/apache/maven/mercury/repository/local/m2/ mercury-repo-remote-m2/src/m...

Author: ogusakov
Date: Wed Jan 21 21:36:03 2009
New Revision: 736568

URL: http://svn.apache.org/viewvc?rev=736568&view=rev
Log:
[MERCURY-76] reading timestampted snapshots correctly

Added:
    maven/mercury/trunk/mercury-repo/mercury-repo-local-m2/src/test/java/org/apache/maven/mercury/repository/local/m2/ArtifactLocationtest.java   (with props)
Modified:
    maven/mercury/trunk/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/ArtifactLocation.java
    maven/mercury/trunk/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/LocalRepositoryReaderM2.java
    maven/mercury/trunk/mercury-repo/mercury-repo-remote-m2/src/main/java/org/apache/maven/mercury/repository/remote/m2/RemoteRepositoryReaderM2.java

Modified: maven/mercury/trunk/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/ArtifactLocation.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/ArtifactLocation.java?rev=736568&r1=736567&r2=736568&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/ArtifactLocation.java (original)
+++ maven/mercury/trunk/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/ArtifactLocation.java Wed Jan 21 21:36:03 2009
@@ -101,6 +101,25 @@
     return dav.getBase();
   }
   
+  public String getVersionWithoutTS()
+  {
+    if( version == null )
+      return null;
+    
+    int li = version.lastIndexOf( '-' );
+    
+    if( li < 1 )
+        return version;
+    
+    int li2 = version.substring( 0, li ).lastIndexOf( '-' );
+    
+    if( li2 > 0 )
+        return version.substring( 0, li2 );
+    
+    return version;
+        
+  }
+  
   //---------------------------------------------------------
   public String getGaPath()
   {

Modified: maven/mercury/trunk/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/LocalRepositoryReaderM2.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/LocalRepositoryReaderM2.java?rev=736568&r1=736567&r2=736568&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/LocalRepositoryReaderM2.java (original)
+++ maven/mercury/trunk/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/LocalRepositoryReaderM2.java Wed Jan 21 21:36:03 2009
@@ -194,7 +194,7 @@
         // time stamped snapshot requested
         else if ( vq.equals( Quality.SNAPSHOT_TS_QUALITY ) )
         {
-            loc.setVersionDir( loc.getBaseVersion() + FileUtil.DASH + Artifact.SNAPSHOT_VERSION );
+            loc.setVersionDir( loc.getVersionWithoutTS() + FileUtil.DASH + Artifact.SNAPSHOT_VERSION );
         }
 
         return loc;

Added: maven/mercury/trunk/mercury-repo/mercury-repo-local-m2/src/test/java/org/apache/maven/mercury/repository/local/m2/ArtifactLocationtest.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-repo/mercury-repo-local-m2/src/test/java/org/apache/maven/mercury/repository/local/m2/ArtifactLocationtest.java?rev=736568&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-repo/mercury-repo-local-m2/src/test/java/org/apache/maven/mercury/repository/local/m2/ArtifactLocationtest.java (added)
+++ maven/mercury/trunk/mercury-repo/mercury-repo-local-m2/src/test/java/org/apache/maven/mercury/repository/local/m2/ArtifactLocationtest.java Wed Jan 21 21:36:03 2009
@@ -0,0 +1,67 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+*/
+
+package org.apache.maven.mercury.repository.local.m2;
+
+import org.apache.maven.mercury.artifact.ArtifactBasicMetadata;
+
+import junit.framework.TestCase;
+
+/**
+ *
+ *
+ * @author Oleg Gusakov
+ * @version $Id$
+ *
+ */
+public class ArtifactLocationtest
+    extends TestCase
+{
+
+    protected void setUp()
+        throws Exception
+    {
+    }
+    
+    public void testChopTS()
+    throws Exception
+    {
+        ArtifactLocation loc = new ArtifactLocation( "test", new ArtifactBasicMetadata("a:a:3.0-alpha-1-20080920.015600-7") );
+        
+        String chop = loc.getVersionWithoutTS();
+        
+        assertEquals( "3.0-alpha-1", chop );
+
+        
+        loc = new ArtifactLocation( "test", new ArtifactBasicMetadata("a:a:3.0-20080920.015600-7") );
+        
+        chop = loc.getVersionWithoutTS();
+        
+        assertEquals( "3.0", chop );
+
+
+        loc = new ArtifactLocation( "test", new ArtifactBasicMetadata("a:a:3.0-20080920.0156007") );
+        
+        chop = loc.getVersionWithoutTS();
+        
+        assertEquals( "3.0-20080920.0156007", chop );
+    }
+
+
+}

Propchange: maven/mercury/trunk/mercury-repo/mercury-repo-local-m2/src/test/java/org/apache/maven/mercury/repository/local/m2/ArtifactLocationtest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/mercury/trunk/mercury-repo/mercury-repo-local-m2/src/test/java/org/apache/maven/mercury/repository/local/m2/ArtifactLocationtest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: maven/mercury/trunk/mercury-repo/mercury-repo-remote-m2/src/main/java/org/apache/maven/mercury/repository/remote/m2/RemoteRepositoryReaderM2.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-repo/mercury-repo-remote-m2/src/main/java/org/apache/maven/mercury/repository/remote/m2/RemoteRepositoryReaderM2.java?rev=736568&r1=736567&r2=736568&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-repo/mercury-repo-remote-m2/src/main/java/org/apache/maven/mercury/repository/remote/m2/RemoteRepositoryReaderM2.java (original)
+++ maven/mercury/trunk/mercury-repo/mercury-repo-remote-m2/src/main/java/org/apache/maven/mercury/repository/remote/m2/RemoteRepositoryReaderM2.java Wed Jan 21 21:36:03 2009
@@ -226,7 +226,7 @@
     // time stamped snapshot requested
     else if( vq.equals( Quality.SNAPSHOT_TS_QUALITY ))
     {
-      loc.setVersionDir( loc.getBaseVersion()+FileUtil.DASH+Artifact.SNAPSHOT_VERSION );
+      loc.setVersionDir( loc.getVersionWithoutTS()+FileUtil.DASH+Artifact.SNAPSHOT_VERSION );
     }
     
     return loc;