You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2020/06/11 19:26:39 UTC

[maven-artifact-transfer] branch MSHARED-922 created (now b516729)

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

michaelo pushed a change to branch MSHARED-922
in repository https://gitbox.apache.org/repos/asf/maven-artifact-transfer.git.


      at b516729  [MSHARED-922] Remove checksum calculation from DefaultProjectDeployer

This branch includes the following new commits:

     new b516729  [MSHARED-922] Remove checksum calculation from DefaultProjectDeployer

The 1 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.



[maven-artifact-transfer] 01/01: [MSHARED-922] Remove checksum calculation from DefaultProjectDeployer

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch MSHARED-922
in repository https://gitbox.apache.org/repos/asf/maven-artifact-transfer.git

commit b5167293fa2dfa6e23542fa7b7c16abb32bd6858
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Thu Jun 11 12:24:18 2020 +0200

    [MSHARED-922] Remove checksum calculation from DefaultProjectDeployer
    
    The checksums are generated by Maven Resolver
    
    This closes #16
---
 .../deploy/internal/DefaultProjectDeployer.java    |  94 -----------------
 .../project/deploy/internal/DualDigester.java      | 115 ---------------------
 2 files changed, 209 deletions(-)

diff --git a/src/main/java/org/apache/maven/shared/transfer/project/deploy/internal/DefaultProjectDeployer.java b/src/main/java/org/apache/maven/shared/transfer/project/deploy/internal/DefaultProjectDeployer.java
index 1a066dc..166ca24 100644
--- a/src/main/java/org/apache/maven/shared/transfer/project/deploy/internal/DefaultProjectDeployer.java
+++ b/src/main/java/org/apache/maven/shared/transfer/project/deploy/internal/DefaultProjectDeployer.java
@@ -20,7 +20,6 @@ package org.apache.maven.shared.transfer.project.deploy.internal;
  */
 
 import java.io.File;
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
@@ -37,7 +36,6 @@ import org.apache.maven.shared.transfer.project.deploy.ProjectDeployerRequest;
 import org.apache.maven.shared.transfer.repository.RepositoryManager;
 import org.codehaus.plexus.component.annotations.Component;
 import org.codehaus.plexus.component.annotations.Requirement;
-import org.codehaus.plexus.util.FileUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -59,8 +57,6 @@ class DefaultProjectDeployer
     @Requirement
     private RepositoryManager repositoryManager;
 
-    private final DualDigester digester = new DualDigester();
-
     /**
      * {@inheritDoc}
      */
@@ -127,7 +123,6 @@ class DefaultProjectDeployer
             deployableArtifacts.add( attached );
         }
 
-        installChecksumsForAllArtifacts( buildingRequest, deployableArtifacts );
         deploy( buildingRequest, deployableArtifacts, artifactRepository, retryFailedDeploymentCount );
     }
 
@@ -149,23 +144,6 @@ class DefaultProjectDeployer
         }
     }
 
-    private void installChecksumsForAllArtifacts( ProjectBuildingRequest request, Collection<Artifact> artifacts )
-    {
-        for ( Artifact item : artifacts )
-        {
-            try
-            {
-                LOGGER.debug( "Installing checksum for " + item.getId() );
-                installChecksums( request, item );
-            }
-            catch ( IOException e )
-            {
-                // THINK HARD ABOUT IT
-                LOGGER.error( "Failure during checksum generation for " + item.getId() );
-            }
-        }
-    }
-
     private void deploy( ProjectBuildingRequest request, Collection<Artifact> artifacts,
                          ArtifactRepository deploymentRepository, int retryFailedDeploymentCount )
         throws ArtifactDeployerException
@@ -207,76 +185,4 @@ class DefaultProjectDeployer
         }
     }
 
-    /**
-     * @param buildingRequest The project building request, must not be <code>null</code>.
-     * @param artifact The artifact for which to create checksums, must not be <code>null</code>.
-     * @throws IOException If the checksums could not be installed.
-     */
-    private void installChecksums( ProjectBuildingRequest buildingRequest, Artifact artifact )
-        throws IOException
-    {
-        File artifactFile = getLocalRepoFile( buildingRequest, artifact );
-        installChecksums( artifactFile );
-    }
-
-    /**
-     * Installs the checksums for the specified file (if it exists).
-     *
-     * @param installedFile The path to the already installed file in the local repo for which to generate checksums,
-     *            must not be <code>null</code>.
-     * @throws IOException In case of errors. Could not install checksums.
-     */
-    private void installChecksums( File installedFile )
-        throws IOException
-    {
-        boolean signatureFile = installedFile.getName().endsWith( ".asc" );
-        if ( installedFile.isFile() && !signatureFile )
-        {
-            LOGGER.debug( "Calculating checksums for " + installedFile );
-            digester.calculate( installedFile );
-            installChecksum( installedFile, ".md5", digester.getMd5() );
-            installChecksum( installedFile, ".sha1", digester.getSha1() );
-        }
-    }
-
-    /**
-     * Installs a checksum for the specified file.
-     *
-     * @param installedFile The base path from which the path to the checksum files is derived by appending the given
-     *            file extension, must not be <code>null</code>.
-     * @param ext The file extension (including the leading dot) to use for the checksum file, must not be
-     *            <code>null</code>.
-     * @param checksum the checksum to write
-     * @throws IOException If the checksum could not be installed.
-     */
-    private void installChecksum( File installedFile, String ext, String checksum )
-        throws IOException
-    {
-        File checksumFile = new File( installedFile.getAbsolutePath() + ext );
-        LOGGER.debug( "Installing checksum to " + checksumFile );
-        try
-        {
-            // noinspection ResultOfMethodCallIgnored
-            checksumFile.getParentFile().mkdirs();
-            FileUtils.fileWrite( checksumFile.getAbsolutePath(), "UTF-8", checksum );
-        }
-        catch ( IOException e )
-        {
-            throw new IOException( "Failed to install checksum to " + checksumFile, e );
-        }
-    }
-
-    /**
-     * Gets the path of the specified artifact within the local repository. Note that the returned path need not exist
-     * (yet).
-     *
-     * @param buildingRequest The project building request, must not be <code>null</code>.
-     * @param artifact The artifact whose local repo path should be determined, must not be <code>null</code>.
-     * @return The absolute path to the artifact when installed, never <code>null</code>.
-     */
-    private File getLocalRepoFile( ProjectBuildingRequest buildingRequest, Artifact artifact )
-    {
-        String path = repositoryManager.getPathForLocalArtifact( buildingRequest, artifact );
-        return new File( repositoryManager.getLocalRepositoryBasedir( buildingRequest ), path );
-    }
 }
diff --git a/src/main/java/org/apache/maven/shared/transfer/project/deploy/internal/DualDigester.java b/src/main/java/org/apache/maven/shared/transfer/project/deploy/internal/DualDigester.java
deleted file mode 100644
index 60100dd..0000000
--- a/src/main/java/org/apache/maven/shared/transfer/project/deploy/internal/DualDigester.java
+++ /dev/null
@@ -1,115 +0,0 @@
-package org.apache.maven.shared.transfer.project.deploy.internal;
-
-/*
- * 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 java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-
-import org.apache.commons.codec.binary.Hex;
-import org.codehaus.plexus.util.IOUtil;
-
-
-/**
- * Calculates md5 and sha1 digest.
- * <p/>
- * Todo: Consider using a thread to calculate one of the digests when the files are large; it's fairly slow !
- *
- * @author Kristian Rosenvold
- */
-//TODO: Think about this class if we could use the ChecksumUtils class of
-// aether-util ? I think we need to go via reflection.
-//
-class DualDigester
-{
-    private final MessageDigest md5 = getDigester( "MD5" );
-
-    private final MessageDigest sh1 = getDigester( "SHA-1" );
-
-    private static final int BUFSIZE = 65536 * 2;
-
-    private final byte[] buffer = new byte[BUFSIZE];
-
-    static MessageDigest getDigester( String algorithm )
-    {
-        try
-        {
-            return MessageDigest.getInstance( algorithm );
-        }
-        catch ( NoSuchAlgorithmException e )
-        {
-            throw new RuntimeException( "Unable to initialize digest " + algorithm + " : " + e.getMessage() );
-        }
-    }
-
-    public void calculate( File file ) throws IOException
-    {
-        FileInputStream fis = null;
-
-        try
-        {
-            fis = new FileInputStream( file );
-            calculate( fis );
-            fis.close();
-            fis = null;
-        }
-        catch ( IOException e )
-        {
-            throw new IOException( "Failed to calculate digest checksum for " + file, e );
-        }
-        finally
-        {
-            IOUtil.close( fis );
-        }
-    }
-
-    void calculate( InputStream stream )
-        throws IOException
-    {
-        md5.reset();
-        sh1.reset();
-        update( stream );
-    }
-
-    public String getMd5()
-    {
-        return Hex.encodeHexString( md5.digest() );
-    }
-
-    public String getSha1()
-    {
-        return Hex.encodeHexString( sh1.digest() );
-    }
-
-    private void update( InputStream is )
-        throws IOException
-    {
-        int size = is.read( buffer, 0, BUFSIZE );
-        while ( size >= 0 )
-        {
-            md5.update( buffer, 0, size );
-            sh1.update( buffer, 0, size );
-            size = is.read( buffer, 0, BUFSIZE );
-        }
-    }
-}