diff --git a/maven-repository-converter/src/main/java/org/apache/maven/repository/converter/DefaultRepositoryConverter.java b/maven-repository-converter/src/main/java/org/apache/maven/repository/converter/DefaultRepositoryConverter.java
index eb9878eb5..01dcaf968 100644
--- a/maven-repository-converter/src/main/java/org/apache/maven/repository/converter/DefaultRepositoryConverter.java
+++ b/maven-repository-converter/src/main/java/org/apache/maven/repository/converter/DefaultRepositoryConverter.java
@@ -227,7 +227,7 @@ public class DefaultRepositoryConverter
if ( file.exists() )
{
Metadata metadata = readMetadata( file );
- result |= validateMetadata( metadata, repositoryMetadata, artifact, reporter );
+ result = result && validateMetadata( metadata, repositoryMetadata, artifact, reporter );
}
return result;
@@ -276,7 +276,7 @@ public class DefaultRepositoryConverter
i.hasNext() && !foundVersion; )
{
String version = (String) i.next();
- if ( version.equals( artifact.getVersion() ) )
+ if ( version.equals( artifact.getBaseVersion() ) )
{
foundVersion = true;
}
@@ -292,13 +292,36 @@ public class DefaultRepositoryConverter
else
{
// snapshot metadata
- if ( !metadata.getVersion().equals( artifact.getVersion() ) )
+ if ( !artifact.getBaseVersion().equals( metadata.getVersion() ) )
{
reporter.addFailure( artifact, getI18NString( key + "version" ) );
result = false;
}
- // TODO: build number
+ if ( artifact.isSnapshot() )
+ {
+ Matcher matcher = Artifact.VERSION_FILE_PATTERN.matcher( artifact.getVersion() );
+ if ( matcher.matches() )
+ {
+ boolean correct = false;
+ if ( metadata.getVersioning() != null && metadata.getVersioning().getSnapshot() != null )
+ {
+ Snapshot snapshot = metadata.getVersioning().getSnapshot();
+ int build = Integer.valueOf( matcher.group( 3 ) ).intValue();
+ String ts = matcher.group( 2 );
+ if ( build == snapshot.getBuildNumber() && ts.equals( snapshot.getTimestamp() ) )
+ {
+ correct = true;
+ }
+ }
+
+ if ( !correct )
+ {
+ reporter.addFailure( artifact, getI18NString( key + "snapshot" ) );
+ result = false;
+ }
+ }
+ }
}
}
return result;
diff --git a/maven-repository-converter/src/test/java/org/apache/maven/repository/converter/RepositoryConverterTest.java b/maven-repository-converter/src/test/java/org/apache/maven/repository/converter/RepositoryConverterTest.java
index 064ddbc76..ad8363047 100644
--- a/maven-repository-converter/src/test/java/org/apache/maven/repository/converter/RepositoryConverterTest.java
+++ b/maven-repository-converter/src/test/java/org/apache/maven/repository/converter/RepositoryConverterTest.java
@@ -731,7 +731,6 @@ public class RepositoryConverterTest
{
// test artifact is not converted when source snapshot metadata is invalid and returns failure
-/* TODO:
createModernSourceRepository();
Artifact artifact = createArtifact( "test", "incorrectSnapshotMetadata", "1.0.0-20060102.030405-6" );
@@ -749,7 +748,6 @@ public class RepositoryConverterTest
File metadataFile =
new File( targetRepository.getBasedir(), targetRepository.pathOfRemoteRepositoryMetadata( metadata ) );
assertFalse( "Check metadata not created", metadataFile.exists() );
-*/
}
public void testMergeArtifactMetadata()
diff --git a/maven-repository-converter/src/test/source-modern-repository/test/incorrectSnapshotMetadata/1.0.0-SNAPSHOT/maven-metadata.xml b/maven-repository-converter/src/test/source-modern-repository/test/incorrectSnapshotMetadata/1.0.0-SNAPSHOT/maven-metadata.xml
new file mode 100644
index 000000000..031fb19b6
--- /dev/null
+++ b/maven-repository-converter/src/test/source-modern-repository/test/incorrectSnapshotMetadata/1.0.0-SNAPSHOT/maven-metadata.xml
@@ -0,0 +1,27 @@
+
+
+
+ test
+ incorrectSnapshotMetadata
+ 1.0.0-SNAPSHOT
+
+
+ 10
+ 20060102.040506
+
+
+
\ No newline at end of file
diff --git a/maven-repository-converter/src/test/source-modern-repository/test/incorrectSnapshotMetadata/maven-metadata.xml b/maven-repository-converter/src/test/source-modern-repository/test/incorrectSnapshotMetadata/maven-metadata.xml
new file mode 100644
index 000000000..db6ce9a7f
--- /dev/null
+++ b/maven-repository-converter/src/test/source-modern-repository/test/incorrectSnapshotMetadata/maven-metadata.xml
@@ -0,0 +1,25 @@
+
+
+
+ test
+ incorrectSnapshotMetadata
+
+
+ 1.0.0-SNAPSHOT
+
+
+
\ No newline at end of file