[maven] branch MNG-6754 updated (a55757b -> 69df0e3)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[maven] branch MNG-6754 updated (a55757b -> 69df0e3)

michaelo
This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a change to branch MNG-6754
in repository https://gitbox.apache.org/repos/asf/maven.git.


    from a55757b  [MNG-6754] Set the same timestamp in multi module builds
     new aa1dfd8  Apply consistent timestamp to all metadata types
     new 69df0e3  Don't set timestamp when creating

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../artifact/installer/DefaultArtifactInstaller.java      |  1 +
 .../resolver/transform/ReleaseArtifactTransformation.java |  1 +
 .../legacy/resolver/transform/SnapshotTransformation.java |  1 +
 .../repository/metadata/AbstractRepositoryMetadata.java   |  1 -
 .../maven/repository/internal/LocalSnapshotMetadata.java  | 15 ++++++++-------
 .../internal/LocalSnapshotMetadataGenerator.java          |  7 ++++++-
 .../apache/maven/repository/internal/MavenMetadata.java   |  8 ++++++--
 .../maven/repository/internal/MavenSnapshotMetadata.java  |  5 +++--
 .../maven/repository/internal/RemoteSnapshotMetadata.java | 10 +++-------
 .../maven/repository/internal/VersionsMetadata.java       | 13 +++++++------
 .../repository/internal/VersionsMetadataGenerator.java    |  7 ++++++-
 11 files changed, 42 insertions(+), 27 deletions(-)

Reply | Threaded
Open this post in threaded view
|

[maven] 01/02: Apply consistent timestamp to all metadata types

michaelo
This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch MNG-6754
in repository https://gitbox.apache.org/repos/asf/maven.git

commit aa1dfd8acba15a2938a1ded9420d634eebd2839e
Author: Michael Osipov <[hidden email]>
AuthorDate: Sat Oct 17 20:40:38 2020 +0200

    Apply consistent timestamp to all metadata types
---
 .../artifact/installer/DefaultArtifactInstaller.java      |  1 +
 .../resolver/transform/ReleaseArtifactTransformation.java |  1 +
 .../legacy/resolver/transform/SnapshotTransformation.java |  1 +
 .../maven/repository/internal/LocalSnapshotMetadata.java  | 15 ++++++++-------
 .../internal/LocalSnapshotMetadataGenerator.java          |  7 ++++++-
 .../apache/maven/repository/internal/MavenMetadata.java   |  8 ++++++--
 .../maven/repository/internal/MavenSnapshotMetadata.java  |  5 +++--
 .../maven/repository/internal/RemoteSnapshotMetadata.java | 10 +++-------
 .../maven/repository/internal/VersionsMetadata.java       | 13 +++++++------
 .../repository/internal/VersionsMetadataGenerator.java    |  7 ++++++-
 10 files changed, 42 insertions(+), 26 deletions(-)

diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/installer/DefaultArtifactInstaller.java b/maven-compat/src/main/java/org/apache/maven/artifact/installer/DefaultArtifactInstaller.java
index a252975..5deee38 100644
--- a/maven-compat/src/main/java/org/apache/maven/artifact/installer/DefaultArtifactInstaller.java
+++ b/maven-compat/src/main/java/org/apache/maven/artifact/installer/DefaultArtifactInstaller.java
@@ -123,6 +123,7 @@ public class DefaultArtifactInstaller
         }
 
         Versioning versioning = new Versioning();
+        // TODO Should this be changed for MNG-6754 too?
         versioning.updateTimestamp();
         versioning.addVersion( artifact.getBaseVersion() );
         if ( artifact.isRelease() )
diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/ReleaseArtifactTransformation.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/ReleaseArtifactTransformation.java
index 3714924..b1d2c71 100644
--- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/ReleaseArtifactTransformation.java
+++ b/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/ReleaseArtifactTransformation.java
@@ -82,6 +82,7 @@ public class ReleaseArtifactTransformation
     private ArtifactMetadata createMetadata( Artifact artifact )
     {
         Versioning versioning = new Versioning();
+        // TODO Should this be changed for MNG-6754 too?
         versioning.updateTimestamp();
         versioning.addVersion( artifact.getVersion() );
 
diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/SnapshotTransformation.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/SnapshotTransformation.java
index 895b952..1a79049 100644
--- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/SnapshotTransformation.java
+++ b/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/SnapshotTransformation.java
@@ -91,6 +91,7 @@ public class SnapshotTransformation
         {
             Snapshot snapshot = new Snapshot();
 
+            // TODO Should this be changed for MNG-6754 too?
             snapshot.setTimestamp( getDeploymentTimestamp() );
 
             // we update the build number anyway so that it doesn't get lost. It requires the timestamp to take effect
diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/LocalSnapshotMetadata.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/LocalSnapshotMetadata.java
index ce09efd..453e4d2 100644
--- a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/LocalSnapshotMetadata.java
+++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/LocalSnapshotMetadata.java
@@ -22,6 +22,7 @@ package org.apache.maven.repository.internal;
 import java.io.File;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Date;
 import java.util.LinkedHashMap;
 import java.util.Map;
 
@@ -42,15 +43,15 @@ final class LocalSnapshotMetadata
 
     private final boolean legacyFormat;
 
-    LocalSnapshotMetadata( Artifact artifact, boolean legacyFormat )
+    LocalSnapshotMetadata( Artifact artifact, boolean legacyFormat, Date timestamp )
     {
-        super( createMetadata( artifact, legacyFormat ), null );
+        super( createMetadata( artifact, legacyFormat ), null, timestamp );
         this.legacyFormat = legacyFormat;
     }
 
-    LocalSnapshotMetadata( Metadata metadata, File file, boolean legacyFormat )
+    LocalSnapshotMetadata( Metadata metadata, File file, boolean legacyFormat, Date timestamp )
     {
-        super( metadata, file );
+        super( metadata, file, timestamp );
         this.legacyFormat = legacyFormat;
     }
 
@@ -82,7 +83,7 @@ final class LocalSnapshotMetadata
 
     public MavenMetadata setFile( File file )
     {
-        return new LocalSnapshotMetadata( metadata, file, legacyFormat );
+        return new LocalSnapshotMetadata( metadata, file, legacyFormat, timestamp );
     }
 
     public Object getKey()
@@ -98,7 +99,7 @@ final class LocalSnapshotMetadata
     @Override
     protected void merge( Metadata recessive )
     {
-        metadata.getVersioning().updateTimestamp();
+        metadata.getVersioning().setLastUpdatedTimestamp( timestamp );
 
         if ( !legacyFormat )
         {
@@ -160,4 +161,4 @@ final class LocalSnapshotMetadata
         return Nature.SNAPSHOT;
     }
 
-}
\ No newline at end of file
+}
diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/LocalSnapshotMetadataGenerator.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/LocalSnapshotMetadataGenerator.java
index 584e166..75b4e6b 100644
--- a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/LocalSnapshotMetadataGenerator.java
+++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/LocalSnapshotMetadataGenerator.java
@@ -21,6 +21,7 @@ package org.apache.maven.repository.internal;
 
 import java.util.Collection;
 import java.util.Collections;
+import java.util.Date;
 import java.util.LinkedHashMap;
 import java.util.Map;
 
@@ -42,10 +43,14 @@ class LocalSnapshotMetadataGenerator
 
     private final boolean legacyFormat;
 
+    private final Date timestamp;
+
     LocalSnapshotMetadataGenerator( RepositorySystemSession session, InstallRequest request )
     {
         legacyFormat = ConfigUtils.getBoolean( session.getConfigProperties(), false, "maven.metadata.legacy" );
 
+        timestamp = (Date) ConfigUtils.getObject( session, new Date(), "maven.startTime" );
+
         snapshots = new LinkedHashMap<>();
     }
 
@@ -59,7 +64,7 @@ class LocalSnapshotMetadataGenerator
                 LocalSnapshotMetadata snapshotMetadata = snapshots.get( key );
                 if ( snapshotMetadata == null )
                 {
-                    snapshotMetadata = new LocalSnapshotMetadata( artifact, legacyFormat );
+                    snapshotMetadata = new LocalSnapshotMetadata( artifact, legacyFormat, timestamp );
                     snapshots.put( key, snapshotMetadata );
                 }
                 snapshotMetadata.bind( artifact );
diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenMetadata.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenMetadata.java
index aef44f6..bdddc70 100644
--- a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenMetadata.java
+++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenMetadata.java
@@ -34,6 +34,7 @@ import java.io.IOException;
 import java.io.Reader;
 import java.io.Writer;
 import java.util.Collections;
+import java.util.Date;
 import java.util.Map;
 
 /**
@@ -46,16 +47,19 @@ abstract class MavenMetadata
 
     static final String MAVEN_METADATA_XML = "maven-metadata.xml";
 
+    protected Metadata metadata;
+
     private final File file;
 
-    protected Metadata metadata;
+    protected final Date timestamp;
 
     private boolean merged;
 
-    protected MavenMetadata( Metadata metadata, File file )
+    protected MavenMetadata( Metadata metadata, File file, Date timestamp )
     {
         this.metadata = metadata;
         this.file = file;
+        this.timestamp = timestamp;
     }
 
     public String getType()
diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenSnapshotMetadata.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenSnapshotMetadata.java
index e4c9a7e..35d4d42 100644
--- a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenSnapshotMetadata.java
+++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenSnapshotMetadata.java
@@ -22,6 +22,7 @@ package org.apache.maven.repository.internal;
 import java.io.File;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Date;
 
 import org.apache.maven.artifact.repository.metadata.Metadata;
 import org.eclipse.aether.artifact.Artifact;
@@ -38,9 +39,9 @@ abstract class MavenSnapshotMetadata
 
     protected final boolean legacyFormat;
 
-    protected MavenSnapshotMetadata( Metadata metadata, File file, boolean legacyFormat )
+    protected MavenSnapshotMetadata( Metadata metadata, File file, boolean legacyFormat, Date timestamp )
     {
-        super( metadata, file );
+        super( metadata, file, timestamp );
         this.legacyFormat = legacyFormat;
     }
 
diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadata.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadata.java
index fe46228..d9b5616 100644
--- a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadata.java
+++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadata.java
@@ -47,18 +47,14 @@ final class RemoteSnapshotMetadata
 
     private final Map<String, SnapshotVersion> versions = new LinkedHashMap<>();
 
-    private final Date timestamp;
-
     RemoteSnapshotMetadata( Artifact artifact, boolean legacyFormat, Date timestamp )
     {
-        super( createRepositoryMetadata( artifact, legacyFormat ), null, legacyFormat );
-        this.timestamp = timestamp;
+        super( createRepositoryMetadata( artifact, legacyFormat ), null, legacyFormat, timestamp );
     }
 
     private RemoteSnapshotMetadata( Metadata metadata, File file, boolean legacyFormat, Date timestamp )
     {
-        super( metadata, file, legacyFormat );
-        this.timestamp = timestamp;
+        super( metadata, file, legacyFormat, timestamp );
     }
 
     public MavenMetadata setFile( File file )
@@ -90,7 +86,7 @@ final class RemoteSnapshotMetadata
 
             Versioning versioning = new Versioning();
             versioning.setSnapshot( snapshot );
-            versioning.setLastUpdated( snapshot.getTimestamp().replace( ".", "" ) );
+            versioning.setLastUpdatedTimestamp( timestamp );
             lastUpdated = versioning.getLastUpdated();
 
             metadata.setVersioning( versioning );
diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadata.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadata.java
index f7df64e..5103e5c 100644
--- a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadata.java
+++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadata.java
@@ -22,6 +22,7 @@ package org.apache.maven.repository.internal;
 import java.io.File;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Date;
 import java.util.LinkedHashSet;
 
 import org.apache.maven.artifact.repository.metadata.Metadata;
@@ -38,15 +39,15 @@ final class VersionsMetadata
 
     private final Artifact artifact;
 
-    VersionsMetadata( Artifact artifact )
+    VersionsMetadata( Artifact artifact, Date timestamp )
     {
-        super( createRepositoryMetadata( artifact ), null );
+        super( createRepositoryMetadata( artifact ), null, timestamp );
         this.artifact = artifact;
     }
 
-    VersionsMetadata( Artifact artifact, File file )
+    VersionsMetadata( Artifact artifact, File file, Date timestamp )
     {
-        super( createRepositoryMetadata( artifact ), file );
+        super( createRepositoryMetadata( artifact ), file, timestamp );
         this.artifact = artifact;
     }
 
@@ -76,7 +77,7 @@ final class VersionsMetadata
     protected void merge( Metadata recessive )
     {
         Versioning versioning = metadata.getVersioning();
-        versioning.updateTimestamp();
+        versioning.setLastUpdatedTimestamp( timestamp );
 
         if ( recessive.getVersioning() != null )
         {
@@ -107,7 +108,7 @@ final class VersionsMetadata
 
     public MavenMetadata setFile( File file )
     {
-        return new VersionsMetadata( artifact, file );
+        return new VersionsMetadata( artifact, file, timestamp );
     }
 
     public String getGroupId()
diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadataGenerator.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadataGenerator.java
index d6b5c8a..409eec4 100644
--- a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadataGenerator.java
+++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadataGenerator.java
@@ -21,6 +21,7 @@ package org.apache.maven.repository.internal;
 
 import java.util.Collection;
 import java.util.Collections;
+import java.util.Date;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.Map;
@@ -31,6 +32,7 @@ import org.eclipse.aether.deployment.DeployRequest;
 import org.eclipse.aether.impl.MetadataGenerator;
 import org.eclipse.aether.installation.InstallRequest;
 import org.eclipse.aether.metadata.Metadata;
+import org.eclipse.aether.util.ConfigUtils;
 
 /**
  * @author Benjamin Bentmann
@@ -43,6 +45,8 @@ class VersionsMetadataGenerator
 
     private Map<Object, VersionsMetadata> processedVersions;
 
+    private final Date timestamp;
+
     VersionsMetadataGenerator( RepositorySystemSession session, InstallRequest request )
     {
         this( session, request.getMetadata() );
@@ -57,6 +61,7 @@ class VersionsMetadataGenerator
     {
         versions = new LinkedHashMap<>();
         processedVersions = new LinkedHashMap<>();
+        timestamp = (Date) ConfigUtils.getObject( session, new Date(), "maven.startTime" );
 
         /*
          * NOTE: This should be considered a quirk to support interop with Maven's legacy ArtifactDeployer which
@@ -96,7 +101,7 @@ class VersionsMetadataGenerator
                 VersionsMetadata versionsMetadata = versions.get( key );
                 if ( versionsMetadata == null )
                 {
-                    versionsMetadata = new VersionsMetadata( artifact );
+                    versionsMetadata = new VersionsMetadata( artifact, timestamp );
                     versions.put( key, versionsMetadata );
                 }
             }

Reply | Threaded
Open this post in threaded view
|

[maven] 02/02: Don't set timestamp when creating

michaelo
In reply to this post by michaelo
This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch MNG-6754
in repository https://gitbox.apache.org/repos/asf/maven.git

commit 69df0e398db4503c8357a915d3668da9e75b5d0b
Author: Michael Osipov <[hidden email]>
AuthorDate: Sat Oct 17 20:41:10 2020 +0200

    Don't set timestamp when creating
   
    This is the same behavior as in
    * org.apache.maven.repository.internal.VersionsMetadata
    * org.apache.maven.repository.internal.LocalSnapshotMetadata
---
 .../maven/artifact/repository/metadata/AbstractRepositoryMetadata.java   | 1 -
 1 file changed, 1 deletion(-)

diff --git a/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/AbstractRepositoryMetadata.java b/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/AbstractRepositoryMetadata.java
index 196b4b7..cc6e982 100644
--- a/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/AbstractRepositoryMetadata.java
+++ b/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/AbstractRepositoryMetadata.java
@@ -164,7 +164,6 @@ public abstract class AbstractRepositoryMetadata
     {
         Versioning versioning = new Versioning();
         versioning.setSnapshot( snapshot );
-        versioning.updateTimestamp();
         return versioning;
     }