You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2020/11/29 13:44:54 UTC

[maven] branch MNG-5728 updated: Map checksumPolicies of ArtifactRepositoryPolicy to RepositoryPolicy, applying a the default.

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

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


The following commit(s) were added to refs/heads/MNG-5728 by this push:
     new 8f57479  Map checksumPolicies of ArtifactRepositoryPolicy to RepositoryPolicy, applying a the default.
8f57479 is described below

commit 8f574798c4b6d6190d3e144ce27655ba83db94ed
Author: rfscholte <rf...@apache.org>
AuthorDate: Sun Nov 29 14:44:43 2020 +0100

    Map checksumPolicies of ArtifactRepositoryPolicy to RepositoryPolicy, applying a the default.
---
 .../repository/internal/ArtifactDescriptorUtils.java   | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/ArtifactDescriptorUtils.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/ArtifactDescriptorUtils.java
index 1e2f99d..a077944 100644
--- a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/ArtifactDescriptorUtils.java
+++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/ArtifactDescriptorUtils.java
@@ -19,6 +19,7 @@ package org.apache.maven.repository.internal;
  * under the License.
  */
 
+import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
 import org.apache.maven.model.Repository;
 import org.eclipse.aether.artifact.Artifact;
 import org.eclipse.aether.artifact.DefaultArtifact;
@@ -59,7 +60,7 @@ public class ArtifactDescriptorUtils
     public static RepositoryPolicy toRepositoryPolicy( org.apache.maven.model.RepositoryPolicy policy )
     {
         boolean enabled = true;
-        String checksums = RepositoryPolicy.CHECKSUM_POLICY_FAIL;
+        String checksums = toRepositoryChecksumPolicy( ArtifactRepositoryPolicy.DEFAULT_CHECKSUM_POLICY );
         String updates = RepositoryPolicy.UPDATE_POLICY_DAILY;
 
         if ( policy != null )
@@ -78,4 +79,19 @@ public class ArtifactDescriptorUtils
         return new RepositoryPolicy( enabled, updates, checksums );
     }
 
+    public static String toRepositoryChecksumPolicy( final String artifactRepositoryPolicy )
+    {
+        switch ( artifactRepositoryPolicy )
+        {
+            case ArtifactRepositoryPolicy.CHECKSUM_POLICY_FAIL:
+                return RepositoryPolicy.CHECKSUM_POLICY_FAIL;
+            case ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE:
+                return RepositoryPolicy.CHECKSUM_POLICY_IGNORE;
+            case ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN:
+                return RepositoryPolicy.CHECKSUM_POLICY_WARN;
+            default:
+                throw new IllegalStateException( "unknown repository checksum policy: " + artifactRepositoryPolicy );
+        }
+    }
+
 }