brett 2005/04/04 18:58:33
Modified: maven-artifact/src/main/java/org/apache/maven/artifact/metadata
SnapshotArtifactMetadata.java
maven-artifact/src/main/java/org/apache/maven/artifact/transform
SnapshotTransformation.java
Log:
use a local snapshot if its file timestamp is newer than the remote timestamp
inside the version file. This opens us back up to clock skew again, but should
be preferential to local snapshots and less confusing
Revision Changes Path
1.14 +18 -1
maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/metadata/SnapshotArtifactMetadata.java
Index: SnapshotArtifactMetadata.java
===================================================================
RCS file:
/home/cvs/maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/metadata/SnapshotArtifactMetadata.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- SnapshotArtifactMetadata.java 4 Apr 2005 16:02:48 -0000 1.13
+++ SnapshotArtifactMetadata.java 5 Apr 2005 01:58:33 -0000 1.14
@@ -230,4 +230,21 @@
{
return lastModified;
}
+
+ public boolean newerThanFile( File file )
+ {
+ long fileTime = file.lastModified();
+
+ // previous behaviour - compare based on timestamp of file
+ // problem was that version.txt is often updated even if the remote
snapshot was not
+ // return ( lastModified > fileTime );
+
+ // Compare to timestamp
+ if ( timestamp != null )
+ {
+ String fileTimestamp = getUtcDateFormatter().format( new Date(
fileTime ) );
+ return ( fileTimestamp.compareTo( timestamp ) < 0 );
+ }
+ return true;
+ }
}
1.18 +2 -2
maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/transform/SnapshotTransformation.java
Index: SnapshotTransformation.java
===================================================================
RCS file:
/home/cvs/maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/transform/SnapshotTransformation.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- SnapshotTransformation.java 31 Mar 2005 07:04:10 -0000 1.17
+++ SnapshotTransformation.java 5 Apr 2005 01:58:33 -0000 1.18
@@ -46,7 +46,7 @@
private WagonManager wagonManager;
/**
- * @todo very primitve. Probably we can resolvedArtifactCache artifacts
themselves in a central location, as well as reset the flag over time in a long
running process.
+ * @todo very primitve. Probably we can cache artifacts themselves in a
central location, as well as reset the flag over time in a long running process.
*/
private static Set resolvedArtifactCache = new HashSet();
@@ -133,7 +133,7 @@
}
// TODO: if the POM and JAR are inconsistent, this might mean
that different version of each are used
- if ( artifact.getFile().exists() &&
artifact.getFile().lastModified() > localMetadata.getLastModified() )
+ if ( artifact.getFile().exists() &&
!localMetadata.newerThanFile( artifact.getFile() ) )
{
if ( !alreadyResolved )
{