michael-o commented on a change in pull request #141:
URL: https://github.com/apache/maven-resolver/pull/141#discussion_r795200766



##########
File path: 
maven-resolver-connector-basic/src/main/java/org/eclipse/aether/connector/basic/BasicRepositoryConnectorFactory.java
##########
@@ -132,6 +143,22 @@ public BasicRepositoryConnectorFactory setFileProcessor( 
FileProcessor fileProce
         return this;
     }
 
+    /**
+     * Sets the provided checksum sources to use for this component.
+     *
+     * @param providedChecksumsSources The provided checksum sources to use, 
must not be {@code null}.
+     * @return This component for chaining, never {@code null}.
+     * @since TBD
+     */
+    public BasicRepositoryConnectorFactory setProvidedChecksumSources(
+        Map<String, ProvidedChecksumsSource> providedChecksumsSources )
+    {
+        this.providedChecksumsSources = requireNonNull(
+            providedChecksumsSources, "provided checksum sources cannot be 
null "

Review comment:
       Trailing space

##########
File path: 
maven-resolver-impl/src/main/java/org/eclipse/aether/impl/guice/AetherModule.java
##########
@@ -207,6 +212,17 @@ protected void configure()
 
     }
 
+    @Provides
+    @Singleton
+    Map<String, ProvidedChecksumsSource> provideChecksumSources(
+        @Named( FileProvidedChecksumSource.NAME ) ProvidedChecksumsSource 
fileDownloadChecksumSource
+    )
+    {
+        Map<String, ProvidedChecksumsSource> downloadChecksumSources = new 
HashMap<>();

Review comment:
       Same here

##########
File path: 
maven-resolver-impl/src/main/java/org/eclipse/aether/impl/guice/AetherModule.java
##########
@@ -207,6 +212,17 @@ protected void configure()
 
     }
 
+    @Provides
+    @Singleton
+    Map<String, ProvidedChecksumsSource> provideChecksumSources(
+        @Named( FileProvidedChecksumSource.NAME ) ProvidedChecksumsSource 
fileDownloadChecksumSource

Review comment:
       Is `fileDownloadChecksumSource` still correct?

##########
File path: 
maven-resolver-spi/src/main/java/org/eclipse/aether/spi/connector/checksum/ChecksumPolicy.java
##########
@@ -64,53 +64,71 @@
  */
 public interface ChecksumPolicy
 {
-
     /**
-     * Bit flag indicating a checksum which is not part of the official 
repository layout/structure.
+     * Enum denoting origin of checksum.
+     *
+     * @since TBD
      */
-    int KIND_UNOFFICIAL = 0x01;
+    enum ChecksumKind
+    {
+        /**
+         * Remote external kind of checksum are retrieved from remote doing 
extra transport round-trip (usually by
+         * getting "file.jar.sha1" for corresponding "file.jar" file). This 
kind of checksum is part of layout, and
+         * was from beginning the "official" (and one and only) checksum used 
by resolver.
+         */
+        REMOTE_EXTERNAL,
+
+        /**
+         * Included checksums may be received from remote repository during 
the retrieval of the main file, for example
+         * from response headers in case of HTTP transport. They may be set 
with
+         * {@link 
org.eclipse.aether.spi.connector.transport.GetTask#setChecksum(String, 
String)}. These are also
+         * known as "smart checksums".

Review comment:
       I wouldn't really use the term "smart chksm" in a new documentation 
because there is nothing smart about it.

##########
File path: 
maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/FileProvidedChecksumSource.java
##########
@@ -0,0 +1,193 @@
+package org.eclipse.aether.internal.impl;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.spi.connector.ArtifactDownload;
+import org.eclipse.aether.spi.connector.MetadataDownload;
+import org.eclipse.aether.spi.connector.checksum.ChecksumAlgorithmFactory;
+import org.eclipse.aether.spi.connector.checksum.ProvidedChecksumsSource;
+import org.eclipse.aether.spi.io.FileProcessor;
+import org.eclipse.aether.util.ConfigUtils;
+import org.eclipse.aether.util.artifact.ArtifactIdUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static java.util.Objects.requireNonNull;
+
+/**
+ * Local filesystem backed {@link ProvidedChecksumsSource} implementation that 
use specified directory as base
+ * directory, where it expects artifacts checksums on standard Maven2 "local" 
layout. This implementation uses Artifact
+ * (and Metadata) coordinates solely to form path from baseDir (for Metadata 
file name is
+ * {@code maven-metadata-local.xml.sha1} in case of SHA-1 checksum).
+ *
+ * @since TBD
+ */
+@Singleton
+@Named( FileProvidedChecksumSource.NAME )
+public final class FileProvidedChecksumSource
+    implements ProvidedChecksumsSource
+{
+    public static final String NAME = "file";
+
+    static final String CONFIG_PROP_BASE_DIR = 
"aether.artifactResolver.providedChecksumSource.file.baseDir";

Review comment:
       `providedChecksumsSource`

##########
File path: 
maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/FileProvidedChecksumSource.java
##########
@@ -0,0 +1,193 @@
+package org.eclipse.aether.internal.impl;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.spi.connector.ArtifactDownload;
+import org.eclipse.aether.spi.connector.MetadataDownload;
+import org.eclipse.aether.spi.connector.checksum.ChecksumAlgorithmFactory;
+import org.eclipse.aether.spi.connector.checksum.ProvidedChecksumsSource;
+import org.eclipse.aether.spi.io.FileProcessor;
+import org.eclipse.aether.util.ConfigUtils;
+import org.eclipse.aether.util.artifact.ArtifactIdUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static java.util.Objects.requireNonNull;
+
+/**
+ * Local filesystem backed {@link ProvidedChecksumsSource} implementation that 
use specified directory as base
+ * directory, where it expects artifacts checksums on standard Maven2 "local" 
layout. This implementation uses Artifact
+ * (and Metadata) coordinates solely to form path from baseDir (for Metadata 
file name is
+ * {@code maven-metadata-local.xml.sha1} in case of SHA-1 checksum).

Review comment:
       Isn't this rather `{repoId}` depending where the data came from?

##########
File path: 
maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/FileProvidedChecksumSource.java
##########
@@ -0,0 +1,193 @@
+package org.eclipse.aether.internal.impl;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.spi.connector.ArtifactDownload;
+import org.eclipse.aether.spi.connector.MetadataDownload;
+import org.eclipse.aether.spi.connector.checksum.ChecksumAlgorithmFactory;
+import org.eclipse.aether.spi.connector.checksum.ProvidedChecksumsSource;
+import org.eclipse.aether.spi.io.FileProcessor;
+import org.eclipse.aether.util.ConfigUtils;
+import org.eclipse.aether.util.artifact.ArtifactIdUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static java.util.Objects.requireNonNull;
+
+/**
+ * Local filesystem backed {@link ProvidedChecksumsSource} implementation that 
use specified directory as base
+ * directory, where it expects artifacts checksums on standard Maven2 "local" 
layout. This implementation uses Artifact
+ * (and Metadata) coordinates solely to form path from baseDir (for Metadata 
file name is
+ * {@code maven-metadata-local.xml.sha1} in case of SHA-1 checksum).
+ *
+ * @since TBD
+ */
+@Singleton
+@Named( FileProvidedChecksumSource.NAME )
+public final class FileProvidedChecksumSource
+    implements ProvidedChecksumsSource
+{
+    public static final String NAME = "file";
+
+    static final String CONFIG_PROP_BASE_DIR = 
"aether.artifactResolver.providedChecksumSource.file.baseDir";
+
+    static final String LOCAL_REPO_PREFIX = ".checksums";
+
+    private static final Logger LOGGER = LoggerFactory.getLogger( 
FileProvidedChecksumSource.class );
+
+    private final FileProcessor fileProcessor;
+
+    private final SimpleLocalRepositoryManager simpleLocalRepositoryManager;
+
+    @Inject
+    public FileProvidedChecksumSource( FileProcessor fileProcessor )
+    {
+        this.fileProcessor = requireNonNull( fileProcessor );
+        // we really needs just "local layout" from it (relative paths), so 
baseDir here is irrelevant
+        this.simpleLocalRepositoryManager = new SimpleLocalRepositoryManager( 
new File( "" ) );
+    }
+
+    @Override
+    public Map<String, String> getProvidedMetadataChecksums( 
RepositorySystemSession session,
+                                                             MetadataDownload 
transfer,
+                                                             
List<ChecksumAlgorithmFactory> checksumAlgorithmFactories )
+    {
+        Path baseDir = getBaseDir( session );
+        if ( baseDir == null )
+        {
+            return null;
+        }
+        ArrayList<ChecksumLocation> checksumLocations = new ArrayList<>( 
checksumAlgorithmFactories.size() );
+        for ( ChecksumAlgorithmFactory checksumAlgorithmFactory : 
checksumAlgorithmFactories )
+        {
+            checksumLocations.add( new ChecksumLocation(

Review comment:
       Hmm, I confused this `ChecksumLocation` with the public one...

##########
File path: 
maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/FileProvidedChecksumSource.java
##########
@@ -0,0 +1,193 @@
+package org.eclipse.aether.internal.impl;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.spi.connector.ArtifactDownload;
+import org.eclipse.aether.spi.connector.MetadataDownload;
+import org.eclipse.aether.spi.connector.checksum.ChecksumAlgorithmFactory;
+import org.eclipse.aether.spi.connector.checksum.ProvidedChecksumsSource;
+import org.eclipse.aether.spi.io.FileProcessor;
+import org.eclipse.aether.util.ConfigUtils;
+import org.eclipse.aether.util.artifact.ArtifactIdUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static java.util.Objects.requireNonNull;
+
+/**
+ * Local filesystem backed {@link ProvidedChecksumsSource} implementation that 
use specified directory as base
+ * directory, where it expects artifacts checksums on standard Maven2 "local" 
layout. This implementation uses Artifact
+ * (and Metadata) coordinates solely to form path from baseDir (for Metadata 
file name is
+ * {@code maven-metadata-local.xml.sha1} in case of SHA-1 checksum).
+ *
+ * @since TBD
+ */
+@Singleton
+@Named( FileProvidedChecksumSource.NAME )
+public final class FileProvidedChecksumSource

Review comment:
       `FileProvidedChecksumsSource`




-- 
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