archiva-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r892790 - in /archiva/branches/MRM-1025/archiva-modules/plugins/maven2-repository/src: main/java/org/apache/archiva/metadata/repository/storage/maven2/ test/java/org/apache/archiva/metadata/repository/storage/maven2/
Date Mon, 21 Dec 2009 12:12:59 GMT
Author: brett
Date: Mon Dec 21 12:12:58 2009
New Revision: 892790

URL: http://svn.apache.org/viewvc?rev=892790&view=rev
Log:
[MRM-1282] make sure snapshot artifact versions are processed correctly

Modified:
    archiva/branches/MRM-1025/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolver.java
    archiva/branches/MRM-1025/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverTest.java

Modified: archiva/branches/MRM-1025/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolver.java
URL: http://svn.apache.org/viewvc/archiva/branches/MRM-1025/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolver.java?rev=892790&r1=892789&r2=892790&view=diff
==============================================================================
--- archiva/branches/MRM-1025/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolver.java
(original)
+++ archiva/branches/MRM-1025/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolver.java
Mon Dec 21 12:12:58 2009
@@ -28,6 +28,8 @@
 import java.util.Collections;
 import java.util.Date;
 import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import org.apache.archiva.checksum.ChecksumAlgorithm;
 import org.apache.archiva.checksum.ChecksummedFile;
@@ -482,7 +484,24 @@
                     log.error( "Unable to checksum file " + file + ": " + e.getMessage()
);
                 }
                 metadata.setSize( file.length() );
-                metadata.setVersion( projectVersion );
+
+                // TODO: very crude, migrate the functionality from the repository-layer
here
+                if ( VersionUtil.isGenericSnapshot( projectVersion ) )
+                {
+                    String mainVersion =
+                        projectVersion.substring( 0, projectVersion.length() - 8 ); // 8
is length of "SNAPSHOT"
+                    System.out.println( file.getName() + " " + mainVersion );
+                    Matcher m = Pattern.compile( projectId + "-" + mainVersion + "([0-9]{8}.[0-9]{6}-[0-9]+).*"
).matcher(
+                        file.getName() );
+                    m.matches();
+                    String version = mainVersion + m.group( 1 );
+
+                    metadata.setVersion( version );
+                }
+                else
+                {
+                    metadata.setVersion( projectVersion );
+                }
                 artifacts.add( metadata );
             }
         }

Modified: archiva/branches/MRM-1025/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverTest.java
URL: http://svn.apache.org/viewvc/archiva/branches/MRM-1025/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverTest.java?rev=892790&r1=892789&r2=892790&view=diff
==============================================================================
--- archiva/branches/MRM-1025/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverTest.java
(original)
+++ archiva/branches/MRM-1025/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverTest.java
Mon Dec 21 12:12:58 2009
@@ -359,6 +359,20 @@
         assertArtifact( artifacts.get( 1 ), "plexus-spring-1.2.jar", 0, EMPTY_SHA1, EMPTY_MD5
);
     }
 
+    public void testGetArtifactsTimestampedSnapshots()
+    {
+        List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>(
+            resolver.getArtifacts( TEST_REPO_ID, "com.example.test", "missing-metadata",
"1.0-SNAPSHOT" ) );
+        assertEquals( 1, artifacts.size() );
+
+        ArtifactMetadata artifact = artifacts.get( 0 );
+        assertEquals( "missing-metadata-1.0-20091101.112233-1.pom", artifact.getId() );
+        assertEquals( "com.example.test", artifact.getNamespace() );
+        assertEquals( "missing-metadata", artifact.getProject() );
+        assertEquals( "1.0-20091101.112233-1", artifact.getVersion() );
+        assertEquals( TEST_REPO_ID, artifact.getRepositoryId() );
+    }
+
     private void assertArtifact( ArtifactMetadata artifact, String id, int size, String sha1,
String md5 )
     {
         assertEquals( id, artifact.getId() );



Mime
View raw message