diff options
10 files changed, 123 insertions, 5 deletions
diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/functors/ConsumerWantsFilePredicate.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/functors/ConsumerWantsFilePredicate.java index e11dc6f77..adf75796d 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/functors/ConsumerWantsFilePredicate.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/functors/ConsumerWantsFilePredicate.java @@ -19,14 +19,15 @@ package org.apache.maven.archiva.repository.scanner.functors; * under the License. */ +import java.io.File; +import java.util.List; + import org.apache.commons.collections.Predicate; import org.apache.commons.io.FilenameUtils; import org.apache.maven.archiva.common.utils.BaseFile; import org.apache.maven.archiva.consumers.RepositoryContentConsumer; import org.codehaus.plexus.util.SelectorUtils; -import java.util.List; - /** * ConsumerWantsFilePredicate * @@ -62,8 +63,19 @@ public class ConsumerWantsFilePredicate // Timestamp finished points to the last successful scan, not this current one. if ( basefile.lastModified() < changesSince ) { - // Skip file as no change has occured. - satisfies = false; + // MRM-1246 + // compares the lastModified of the version-level (basefile) and the project-level (parent) metadata + File parent = basefile.getParentFile().getParentFile(); + + if ( parent.lastModified() > basefile.lastModified() ) + { + satisfies = true; + } + else + { + // Skip file as no change has occurred. + satisfies = false; + } } } } diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/metadata/MetadataToolsTest.java b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/metadata/MetadataToolsTest.java index 468a6b3e1..fec4d0150 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/metadata/MetadataToolsTest.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/metadata/MetadataToolsTest.java @@ -130,6 +130,30 @@ public class MetadataToolsTest // } // } + public void testUpdateProjectNonExistingVersion() + throws Exception + { + ManagedRepositoryContent testRepo = createTestRepoContent(); + ProjectReference reference = new ProjectReference(); + reference.setGroupId( "org.apache.archiva.metadata.tests" ); + reference.setArtifactId( "missing_artifact" ); + + prepTestRepo( testRepo, reference ); + + // check metadata prior to update -- should contain the non-existing artifact version + assertProjectMetadata( testRepo, reference, "missing_artifact", new String[] { + "1.0-SNAPSHOT", + "1.1-SNAPSHOT", + "1.2-SNAPSHOT" }, "1.2-SNAPSHOT" , null ); + + tools.updateMetadata( testRepo, reference ); + + // metadata should not contain the non-existing artifact version -- 1.1-SNAPSHOT + assertProjectMetadata( testRepo, reference, "missing_artifact", new String[] { + "1.0-SNAPSHOT", + "1.2-SNAPSHOT" }, "1.2-SNAPSHOT" , null ); + } + public void testUpdateProjectMissingMultipleVersions() throws Exception { @@ -422,6 +446,40 @@ public class MetadataToolsTest assertMetadata( buf.toString(), testRepo, reference ); } + private void assertProjectMetadata( ManagedRepositoryContent testRepo, ProjectReference reference, String artifactId, + String[] expectedVersions, String latestVersion, String releaseVersion ) + throws Exception + { + StringBuilder buf = new StringBuilder(); + buf.append( "<metadata>\n" ); + buf.append( " <groupId>" ).append( reference.getGroupId() ).append( "</groupId>\n" ); + buf.append( " <artifactId>" ).append( reference.getArtifactId() ).append( "</artifactId>\n" ); + + if ( expectedVersions != null ) + { + buf.append( " <versioning>\n" ); + if ( latestVersion != null ) + { + buf.append( " <latest>" ).append( latestVersion ).append( "</latest>\n" ); + } + if ( releaseVersion != null ) + { + buf.append( " <release>" ).append( releaseVersion ).append( "</release>\n" ); + } + + buf.append( " <versions>\n" ); + for ( int i = 0; i < expectedVersions.length; i++ ) + { + buf.append( " <version>" ).append( expectedVersions[i] ).append( "</version>\n" ); + } + buf.append( " </versions>\n" ); + buf.append( " </versioning>\n" ); + } + buf.append( "</metadata>" ); + + assertMetadata( buf.toString(), testRepo, reference ); + } + private void assertUpdatedReleaseVersionMetadata( String artifactId, String version ) throws Exception { diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/RepositoryScannerTest.java b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/RepositoryScannerTest.java index 22cd183b0..f7451460c 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/RepositoryScannerTest.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/RepositoryScannerTest.java @@ -140,7 +140,7 @@ public class RepositoryScannerTest assertNotNull( "Stats should not be null.", stats ); assertEquals( "Stats.totalFileCount", 4, stats.getTotalFileCount() ); assertEquals( "Stats.newFileCount", 3, stats.getNewFileCount() ); - assertEquals( "Processed Count", 2, consumer.getProcessCount() ); + assertEquals( "Processed Count", 3, consumer.getProcessCount() ); assertEquals( "Processed Count (of invalid items)", 1, badconsumer.getProcessCount() ); } diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/test/repositories/metadata-repository/org/apache/archiva/metadata/tests/missing_artifact/1.0-SNAPSHOT/maven-metadata.xml b/archiva-modules/archiva-base/archiva-repository-layer/src/test/repositories/metadata-repository/org/apache/archiva/metadata/tests/missing_artifact/1.0-SNAPSHOT/maven-metadata.xml new file mode 100644 index 000000000..e8840e709 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/test/repositories/metadata-repository/org/apache/archiva/metadata/tests/missing_artifact/1.0-SNAPSHOT/maven-metadata.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<metadata> + <groupId>org.apache.archiva.metadata.tests</groupId> + <artifactId>missing_artifact</artifactId> + <version>1.0-SNAPSHOT</version> + <versioning> + <snapshot> + <buildNumber>1</buildNumber> + <timestamp>20091007.132409</timestamp> + </snapshot> + </versioning> +</metadata> diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/test/repositories/metadata-repository/org/apache/archiva/metadata/tests/missing_artifact/1.0-SNAPSHOT/missing_artifact-1.0-20091007.132409-1.jar b/archiva-modules/archiva-base/archiva-repository-layer/src/test/repositories/metadata-repository/org/apache/archiva/metadata/tests/missing_artifact/1.0-SNAPSHOT/missing_artifact-1.0-20091007.132409-1.jar new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/test/repositories/metadata-repository/org/apache/archiva/metadata/tests/missing_artifact/1.0-SNAPSHOT/missing_artifact-1.0-20091007.132409-1.jar diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/test/repositories/metadata-repository/org/apache/archiva/metadata/tests/missing_artifact/1.0-SNAPSHOT/missing_artifact-1.0-20091007.132409-1.pom b/archiva-modules/archiva-base/archiva-repository-layer/src/test/repositories/metadata-repository/org/apache/archiva/metadata/tests/missing_artifact/1.0-SNAPSHOT/missing_artifact-1.0-20091007.132409-1.pom new file mode 100644 index 000000000..d2c43abe5 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/test/repositories/metadata-repository/org/apache/archiva/metadata/tests/missing_artifact/1.0-SNAPSHOT/missing_artifact-1.0-20091007.132409-1.pom @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?><project> + <modelVersion>4.0.0</modelVersion> + <groupId>org.apache.archiva.metadata.tests</groupId> + <artifactId>missing_artifact</artifactId> + <version>1.0-SNAPSHOT</version> +</project>
\ No newline at end of file diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/test/repositories/metadata-repository/org/apache/archiva/metadata/tests/missing_artifact/1.2-SNAPSHOT/maven-metadata.xml b/archiva-modules/archiva-base/archiva-repository-layer/src/test/repositories/metadata-repository/org/apache/archiva/metadata/tests/missing_artifact/1.2-SNAPSHOT/maven-metadata.xml new file mode 100644 index 000000000..1487bb280 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/test/repositories/metadata-repository/org/apache/archiva/metadata/tests/missing_artifact/1.2-SNAPSHOT/maven-metadata.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?><metadata> + <groupId>org.apache.archiva.metadata.tests</groupId> + <artifactId>missing_artifact</artifactId> + <version>1.2-SNAPSHOT</version> + <versioning> + <snapshot> + <timestamp>20091011.133751</timestamp> + <buildNumber>1</buildNumber> + </snapshot> + </versioning> +</metadata> diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/test/repositories/metadata-repository/org/apache/archiva/metadata/tests/missing_artifact/1.2-SNAPSHOT/missing_artifact-1.2-20091011.133751-1.jar b/archiva-modules/archiva-base/archiva-repository-layer/src/test/repositories/metadata-repository/org/apache/archiva/metadata/tests/missing_artifact/1.2-SNAPSHOT/missing_artifact-1.2-20091011.133751-1.jar new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/test/repositories/metadata-repository/org/apache/archiva/metadata/tests/missing_artifact/1.2-SNAPSHOT/missing_artifact-1.2-20091011.133751-1.jar diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/test/repositories/metadata-repository/org/apache/archiva/metadata/tests/missing_artifact/1.2-SNAPSHOT/missing_artifact-1.2-20091011.133751-1.pom b/archiva-modules/archiva-base/archiva-repository-layer/src/test/repositories/metadata-repository/org/apache/archiva/metadata/tests/missing_artifact/1.2-SNAPSHOT/missing_artifact-1.2-20091011.133751-1.pom new file mode 100644 index 000000000..f68e5230b --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/test/repositories/metadata-repository/org/apache/archiva/metadata/tests/missing_artifact/1.2-SNAPSHOT/missing_artifact-1.2-20091011.133751-1.pom @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?><project> + <modelVersion>4.0.0</modelVersion> + <groupId>org.apache.archiva.metadata.tests</groupId> + <artifactId>missing_artifact</artifactId> + <version>1.2-SNAPSHOT</version> +</project>
\ No newline at end of file diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/test/repositories/metadata-repository/org/apache/archiva/metadata/tests/missing_artifact/maven-metadata.xml b/archiva-modules/archiva-base/archiva-repository-layer/src/test/repositories/metadata-repository/org/apache/archiva/metadata/tests/missing_artifact/maven-metadata.xml new file mode 100644 index 000000000..3867fb5bd --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/test/repositories/metadata-repository/org/apache/archiva/metadata/tests/missing_artifact/maven-metadata.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8"?><metadata> + <groupId>org.apache.archiva.metadata.tests</groupId> + <artifactId>missing_artifact</artifactId> + <versioning> + <latest>1.2-SNAPSHOT</latest> + <versions> + <version>1.0-SNAPSHOT</version> + <version>1.1-SNAPSHOT</version> + <version>1.2-SNAPSHOT</version> + </versions> + </versioning> +</metadata> |