kwin commented on code in PR #1784:
URL: https://github.com/apache/maven-resolver/pull/1784#discussion_r2759997055


##########
maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/Maven2RepositoryLayoutFactory.java:
##########
@@ -69,6 +70,34 @@ public final class Maven2RepositoryLayoutFactory implements 
RepositoryLayoutFact
 
     public static final String DEFAULT_CHECKSUMS_ALGORITHMS = "SHA-1,MD5";
 
+    /**
+     * Comma-separated list of checksum algorithms with which checksums are 
generated and uploaded
+     * with this layout. Resolver by default supports following algorithms: 
MD5, SHA-1, SHA-256 and
+     * SHA-512. New algorithms can be added by implementing 
ChecksumAlgorithmFactory component.
+     *
+     * @since 2.0.15
+     * @configurationSource {@link 
RepositorySystemSession#getConfigProperties()}
+     * @configurationType {@link java.lang.String}
+     * @configurationDefaultValue {@link #DEFAULT_CHECKSUMS_ALGORITHMS}
+     * @configurationRepoIdSuffix Yes
+     */
+    public static final String CONFIG_PROP_UPLOAD_CHECKSUMS_ALGORITHMS =
+            CONFIG_PROPS_PREFIX + "uploadChecksumAlgorithms";
+
+    /**
+     * Comma-separated list of checksum algorithms with which checksums are 
validated (downloaded) with this layout.

Review Comment:
   Please mention which one takes precedence if both 
CONFIG_PROP_CHECKSUMS_ALGORITHMS and this is set.



##########
maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/Maven2RepositoryLayoutFactory.java:
##########
@@ -106,26 +135,54 @@ public RepositoryLayout 
newInstance(RepositorySystemSession session, RemoteRepos
             throw new NoRepositoryLayoutException(repository);
         }
 
-        List<ChecksumAlgorithmFactory> checksumsAlgorithms = 
checksumAlgorithmFactorySelector.selectList(
-                
ConfigUtils.parseCommaSeparatedUniqueNames(ConfigUtils.getString(
-                        session,
-                        DEFAULT_CHECKSUMS_ALGORITHMS,
-                        CONFIG_PROP_CHECKSUMS_ALGORITHMS + "." + 
repository.getId(),
-                        CONFIG_PROP_CHECKSUMS_ALGORITHMS,
-                        // MRESOLVER-701: support legacy properties for 
simpler transitioning
-                        "aether.checksums.algorithms",
-                        "aether.checksums.algorithms." + repository.getId())));
-
-        return new Maven2RepositoryLayout(checksumsAlgorithms, 
artifactPredicateFactory.newInstance(session));
+        // shared property w/ legacy fallback (fallback to default)
+        List<String> checksumsAlgorithmNames = 
ConfigUtils.parseCommaSeparatedUniqueNames(ConfigUtils.getString(
+                session,
+                DEFAULT_CHECKSUMS_ALGORITHMS,
+                CONFIG_PROP_CHECKSUMS_ALGORITHMS + "." + repository.getId(),
+                CONFIG_PROP_CHECKSUMS_ALGORITHMS,
+                // MRESOLVER-701: support legacy properties for simpler 
transitioning
+                "aether.checksums.algorithms." + repository.getId(),
+                "aether.checksums.algorithms"));
+
+        // explicit property for download (will be empty if not configured)
+        List<String> downloadChecksumsAlgorithmNames = 
ConfigUtils.parseCommaSeparatedUniqueNames(ConfigUtils.getString(
+                session,
+                null,
+                CONFIG_PROP_DOWNLOAD_CHECKSUMS_ALGORITHMS + "." + 
repository.getId(),
+                CONFIG_PROP_DOWNLOAD_CHECKSUMS_ALGORITHMS));
+
+        // explicit property for upload (will be empty if not configured)
+        List<String> uploadChecksumsAlgorithmNames = 
ConfigUtils.parseCommaSeparatedUniqueNames(ConfigUtils.getString(
+                session,
+                null,

Review Comment:
   same here



##########
maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/Maven2RepositoryLayoutFactory.java:
##########
@@ -69,6 +70,34 @@ public final class Maven2RepositoryLayoutFactory implements 
RepositoryLayoutFact
 
     public static final String DEFAULT_CHECKSUMS_ALGORITHMS = "SHA-1,MD5";
 
+    /**
+     * Comma-separated list of checksum algorithms with which checksums are 
generated and uploaded

Review Comment:
   Please mention which one takes precedence if both 
CONFIG_PROP_CHECKSUMS_ALGORITHMS and this is set.



##########
maven-resolver-spi/src/main/java/org/eclipse/aether/spi/connector/layout/RepositoryLayout.java:
##########
@@ -115,13 +115,29 @@ public String toString() {
 
     /**
      * Returns immutable list of {@link ChecksumAlgorithmFactory} this 
instance of layout uses, never {@code null}.
-     * The order also represents the order how remote external checksums are 
retrieved and validated.
+     * This (legacy, but not deprecated) method will return <em>all checksums 
this layout uses</em>, but
+     * these may be different in case upload or download checksums are 
explicitly configured. This method will
+     * reflect the checksum order used for download, but may have more 
elements than actually used in download
+     * validation, if the generated checksums for upload has extra elements.
      *
      * @see 
org.eclipse.aether.spi.connector.checksum.ChecksumPolicy.ChecksumKind
+     * @see #getChecksumAlgorithmFactories(boolean)
      * @since 1.8.0
      */
     List<ChecksumAlgorithmFactory> getChecksumAlgorithmFactories();
 
+    /**
+     * Returns immutable list of {@link ChecksumAlgorithmFactory} this 
instance of layout uses for download or upload,
+     * never {@code null}. The order also represents the order how remote 
external checksums are retrieved and
+     * validated (if for download).
+     *

Review Comment:
   There is a missing `@param` here.



##########
maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/Maven2RepositoryLayoutFactory.java:
##########
@@ -106,26 +135,54 @@ public RepositoryLayout 
newInstance(RepositorySystemSession session, RemoteRepos
             throw new NoRepositoryLayoutException(repository);
         }
 
-        List<ChecksumAlgorithmFactory> checksumsAlgorithms = 
checksumAlgorithmFactorySelector.selectList(
-                
ConfigUtils.parseCommaSeparatedUniqueNames(ConfigUtils.getString(
-                        session,
-                        DEFAULT_CHECKSUMS_ALGORITHMS,
-                        CONFIG_PROP_CHECKSUMS_ALGORITHMS + "." + 
repository.getId(),
-                        CONFIG_PROP_CHECKSUMS_ALGORITHMS,
-                        // MRESOLVER-701: support legacy properties for 
simpler transitioning
-                        "aether.checksums.algorithms",
-                        "aether.checksums.algorithms." + repository.getId())));
-
-        return new Maven2RepositoryLayout(checksumsAlgorithms, 
artifactPredicateFactory.newInstance(session));
+        // shared property w/ legacy fallback (fallback to default)
+        List<String> checksumsAlgorithmNames = 
ConfigUtils.parseCommaSeparatedUniqueNames(ConfigUtils.getString(
+                session,
+                DEFAULT_CHECKSUMS_ALGORITHMS,
+                CONFIG_PROP_CHECKSUMS_ALGORITHMS + "." + repository.getId(),
+                CONFIG_PROP_CHECKSUMS_ALGORITHMS,
+                // MRESOLVER-701: support legacy properties for simpler 
transitioning
+                "aether.checksums.algorithms." + repository.getId(),
+                "aether.checksums.algorithms"));
+
+        // explicit property for download (will be empty if not configured)
+        List<String> downloadChecksumsAlgorithmNames = 
ConfigUtils.parseCommaSeparatedUniqueNames(ConfigUtils.getString(
+                session,
+                null,

Review Comment:
   why not passing `checksumsAlgorithmNames` as default.



##########
maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/Maven2RepositoryLayoutFactory.java:
##########
@@ -69,6 +70,34 @@ public final class Maven2RepositoryLayoutFactory implements 
RepositoryLayoutFact
 
     public static final String DEFAULT_CHECKSUMS_ALGORITHMS = "SHA-1,MD5";
 
+    /**
+     * Comma-separated list of checksum algorithms with which checksums are 
generated and uploaded

Review Comment:
   Mentioning these configuration options in the javadoc for 
`CONFIG_PROP_CHECKSUMS_ALGORITHMS` would be helpful.



##########
maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/Maven2RepositoryLayoutFactory.java:
##########
@@ -106,26 +135,54 @@ public RepositoryLayout 
newInstance(RepositorySystemSession session, RemoteRepos
             throw new NoRepositoryLayoutException(repository);
         }
 
-        List<ChecksumAlgorithmFactory> checksumsAlgorithms = 
checksumAlgorithmFactorySelector.selectList(
-                
ConfigUtils.parseCommaSeparatedUniqueNames(ConfigUtils.getString(
-                        session,
-                        DEFAULT_CHECKSUMS_ALGORITHMS,
-                        CONFIG_PROP_CHECKSUMS_ALGORITHMS + "." + 
repository.getId(),
-                        CONFIG_PROP_CHECKSUMS_ALGORITHMS,
-                        // MRESOLVER-701: support legacy properties for 
simpler transitioning
-                        "aether.checksums.algorithms",
-                        "aether.checksums.algorithms." + repository.getId())));
-
-        return new Maven2RepositoryLayout(checksumsAlgorithms, 
artifactPredicateFactory.newInstance(session));
+        // shared property w/ legacy fallback (fallback to default)
+        List<String> checksumsAlgorithmNames = 
ConfigUtils.parseCommaSeparatedUniqueNames(ConfigUtils.getString(
+                session,
+                DEFAULT_CHECKSUMS_ALGORITHMS,
+                CONFIG_PROP_CHECKSUMS_ALGORITHMS + "." + repository.getId(),
+                CONFIG_PROP_CHECKSUMS_ALGORITHMS,
+                // MRESOLVER-701: support legacy properties for simpler 
transitioning
+                "aether.checksums.algorithms." + repository.getId(),
+                "aether.checksums.algorithms"));
+
+        // explicit property for download (will be empty if not configured)
+        List<String> downloadChecksumsAlgorithmNames = 
ConfigUtils.parseCommaSeparatedUniqueNames(ConfigUtils.getString(
+                session,
+                null,
+                CONFIG_PROP_DOWNLOAD_CHECKSUMS_ALGORITHMS + "." + 
repository.getId(),
+                CONFIG_PROP_DOWNLOAD_CHECKSUMS_ALGORITHMS));
+
+        // explicit property for upload (will be empty if not configured)
+        List<String> uploadChecksumsAlgorithmNames = 
ConfigUtils.parseCommaSeparatedUniqueNames(ConfigUtils.getString(
+                session,
+                null,
+                CONFIG_PROP_UPLOAD_CHECKSUMS_ALGORITHMS + "." + 
repository.getId(),
+                CONFIG_PROP_UPLOAD_CHECKSUMS_ALGORITHMS));
+
+        return new Maven2RepositoryLayout(
+                checksumAlgorithmFactorySelector.selectList(

Review Comment:
   instead of implementing the fallback here I would rather do it above.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to