* 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
*
// 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;
+ }
}
}
}
// }
// }
+ 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
{
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
{