You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kh...@apache.org on 2018/06/24 21:44:28 UTC

[maven-artifact-transfer] branch MSHARED-695 updated (a9df80b -> cf55484)

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

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


 discard a9df80b  [MSHARED-695] - WIP - Move checksum generation from install to deploy  o Continued.
 discard fafa70f  [MSHARED-695] - WIP - Move checksum generation from install to deploy  o Continued.
 discard 040d881  Make special version for the branch.
 discard 5672cb9  Upgrade surefire/failsafe to 2.21.0 for JDK 10 build in IT's.
 discard a92204a  Added debug output.
 discard f524570  [MSHARED-695] - WIP - Move checksum generation from install to deploy  o Moved checksum generation into deploy part. Removed checksum from    install.  o Removed it from ProjectInstallerRequest.
 discard c601d79  [MSHARED-695] - WIP - Move checksum generation from install to deploy  o Moved checksum generation into deploy part. Removed checksume from    install
 discard 9faaf33  [MSHARED-695] - WIP - Move checksum generation from install to deploy
 discard 1e4592c  [MSHARED-695] - WIP - Move checksum generation from install to deploy
 discard 354fb0e  [MSHARED-695] - WIP - Move checksum generation from install to deploy
 discard 4aa3f2d  [MSHARED-695] - WIP - Move checksum generation from install to deploy
 discard 0724366  Add JDK10 and test it.
     add 4dc2562  [MSHARED-737] - Upgrade mockito-core to 2.18.3 JDK 10 support  o Updated Jenkinsfile accordingly to build also JDK 10
     new 6fded83  Add JDK10 and test it.
     new e9462a6  [MSHARED-695] - WIP - Move checksum generation from install to deploy
     new 055fece  [MSHARED-695] - WIP - Move checksum generation from install to deploy
     new f0e6968  [MSHARED-695] - WIP - Move checksum generation from install to deploy
     new 941dd5c  [MSHARED-695] - WIP - Move checksum generation from install to deploy
     new 4c60627  [MSHARED-695] - WIP - Move checksum generation from install to deploy  o Moved checksum generation into deploy part. Removed checksume from    install
     new 8511ea1  [MSHARED-695] - WIP - Move checksum generation from install to deploy  o Moved checksum generation into deploy part. Removed checksum from    install.  o Removed it from ProjectInstallerRequest.
     new 763c559  Added debug output.
     new c834261  Upgrade surefire/failsafe to 2.21.0 for JDK 10 build in IT's.
     new ad8e322  Make special version for the branch.
     new 46ae245  [MSHARED-695] - WIP - Move checksum generation from install to deploy  o Continued.
     new cf55484  [MSHARED-695] - WIP - Move checksum generation from install to deploy  o Continued.

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (a9df80b)
            \
             N -- N -- N   refs/heads/MSHARED-695 (cf55484)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 12 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:
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


[maven-artifact-transfer] 08/12: Added debug output.

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

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

commit 763c559adec1b0a595331af856194993ca608e3c
Author: Karl Heinz Marbaise <kh...@apache.org>
AuthorDate: Sun Apr 15 19:28:03 2018 +0200

    Added debug output.
---
 .../maven/shared/project/install/internal/DefaultProjectInstaller.java   | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/main/java/org/apache/maven/shared/project/install/internal/DefaultProjectInstaller.java b/src/main/java/org/apache/maven/shared/project/install/internal/DefaultProjectInstaller.java
index 4e001db..6cb5ad8 100644
--- a/src/main/java/org/apache/maven/shared/project/install/internal/DefaultProjectInstaller.java
+++ b/src/main/java/org/apache/maven/shared/project/install/internal/DefaultProjectInstaller.java
@@ -126,6 +126,7 @@ class DefaultProjectInstaller
 
         for ( Artifact attached : attachedArtifacts )
         {
+            LOGGER.debug( "Installing artifact: ", attached.getId() );
             installer.install( buildingRequest, Collections.singletonList( attached ) );
             addMetaDataFilesForArtifact( buildingRequest, attached, metadataFiles );
         }


[maven-artifact-transfer] 09/12: Upgrade surefire/failsafe to 2.21.0 for JDK 10 build in IT's.

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

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

commit c834261fda21097ac702e3dcd9e16b09757c9a9a
Author: Karl Heinz Marbaise <kh...@apache.org>
AuthorDate: Sun Apr 29 22:04:57 2018 +0200

    Upgrade surefire/failsafe to 2.21.0 for JDK 10 build in IT's.
---
 src/it/maven-artifact-deployer-plugin/pom.xml  | 1 +
 src/it/maven-artifact-installer-plugin/pom.xml | 1 +
 src/it/maven-project-deployer-plugin/pom.xml   | 1 +
 src/it/maven-project-installer-plugin/pom.xml  | 1 +
 4 files changed, 4 insertions(+)

diff --git a/src/it/maven-artifact-deployer-plugin/pom.xml b/src/it/maven-artifact-deployer-plugin/pom.xml
index b0b7287..42f5672 100644
--- a/src/it/maven-artifact-deployer-plugin/pom.xml
+++ b/src/it/maven-artifact-deployer-plugin/pom.xml
@@ -43,6 +43,7 @@
   </prerequisites>
 
   <properties>
+    <surefire.version>2.21.0</surefire.version>
     <mavenVersion>3.0</mavenVersion>
     <javaVersion>8</javaVersion>
   </properties>
diff --git a/src/it/maven-artifact-installer-plugin/pom.xml b/src/it/maven-artifact-installer-plugin/pom.xml
index cbcc032..308d34f 100644
--- a/src/it/maven-artifact-installer-plugin/pom.xml
+++ b/src/it/maven-artifact-installer-plugin/pom.xml
@@ -43,6 +43,7 @@
   </prerequisites>
 
   <properties>
+    <surefire.version>2.21.0</surefire.version>
     <mavenVersion>3.0</mavenVersion>
     <javaVersion>8</javaVersion>
   </properties>
diff --git a/src/it/maven-project-deployer-plugin/pom.xml b/src/it/maven-project-deployer-plugin/pom.xml
index d6eaa8f..baeecc8 100644
--- a/src/it/maven-project-deployer-plugin/pom.xml
+++ b/src/it/maven-project-deployer-plugin/pom.xml
@@ -43,6 +43,7 @@
   </prerequisites>
 
   <properties>
+    <surefire.version>2.21.0</surefire.version>
     <mavenVersion>3.0</mavenVersion>
     <javaVersion>8</javaVersion>
   </properties>
diff --git a/src/it/maven-project-installer-plugin/pom.xml b/src/it/maven-project-installer-plugin/pom.xml
index 5d68af9..f0e0fbd 100644
--- a/src/it/maven-project-installer-plugin/pom.xml
+++ b/src/it/maven-project-installer-plugin/pom.xml
@@ -43,6 +43,7 @@
   </prerequisites>
 
   <properties>
+    <surefire.version>2.21.0</surefire.version>
     <mavenVersion>3.0</mavenVersion>
     <javaVersion>8</javaVersion>
   </properties>


[maven-artifact-transfer] 01/12: Add JDK10 and test it.

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

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

commit 6fded8337f38f2ca9b313ae04601c8e9cb2a7f55
Author: Karl Heinz Marbaise <kh...@apache.org>
AuthorDate: Sun Apr 29 21:33:01 2018 +0200

    Add JDK10 and test it.
---
 Jenkinsfile | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Jenkinsfile b/Jenkinsfile
index fdf3c45..4fc4a3e 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -17,4 +17,7 @@
  * under the License.
  */
 
+// Currently we can only build with JDK8+ based on the usage
+// of takari-plugin-integration-testing within integration
+// tests.
 asfMavenTlpStdBuild( 'jdks' : ["8", "9", "10" ] )


[maven-artifact-transfer] 05/12: [MSHARED-695] - WIP - Move checksum generation from install to deploy

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

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

commit 941dd5c5e517ed8d523f88e4e7646d66c28dfa1b
Author: Karl Heinz Marbaise <kh...@apache.org>
AuthorDate: Sun Apr 8 20:36:19 2018 +0200

    [MSHARED-695] - WIP - Move checksum generation from install to deploy
---
 .../maven/shared/project/deploy/internal/DefaultProjectDeployer.java    | 2 --
 1 file changed, 2 deletions(-)

diff --git a/src/main/java/org/apache/maven/shared/project/deploy/internal/DefaultProjectDeployer.java b/src/main/java/org/apache/maven/shared/project/deploy/internal/DefaultProjectDeployer.java
index e1af430..be95dd7 100644
--- a/src/main/java/org/apache/maven/shared/project/deploy/internal/DefaultProjectDeployer.java
+++ b/src/main/java/org/apache/maven/shared/project/deploy/internal/DefaultProjectDeployer.java
@@ -69,8 +69,6 @@ class DefaultProjectDeployer
                         ArtifactRepository artifactRepository )
         throws NoFileAssignedException, IllegalArgumentException, ArtifactDeployerException
     {
-        boolean createChecksum = true;
-
         validateParameters( buildingRequest, projectDeployerRequest, artifactRepository );
 
         Artifact artifact = projectDeployerRequest.getProject().getArtifact();


[maven-artifact-transfer] 06/12: [MSHARED-695] - WIP - Move checksum generation from install to deploy o Moved checksum generation into deploy part. Removed checksume from install

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

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

commit 4c60627f792f9f7f528a843fcd0ac4d5cc699660
Author: Karl Heinz Marbaise <kh...@apache.org>
AuthorDate: Sun Apr 8 21:08:12 2018 +0200

    [MSHARED-695] - WIP - Move checksum generation from install to deploy
     o Moved checksum generation into deploy part. Removed checksume from
       install
---
 .../project/install/ProjectInstallerTest.java      |  18 +--
 .../install/internal/DefaultProjectInstaller.java  | 124 +--------------------
 .../project/install/internal/DualDigester.java     | 115 -------------------
 .../internal/DualDigesterTest.java                 |   2 +-
 4 files changed, 14 insertions(+), 245 deletions(-)

diff --git a/src/it/maven-project-installer-plugin/src/test/java/org/apache/maven/plugin/project/install/ProjectInstallerTest.java b/src/it/maven-project-installer-plugin/src/test/java/org/apache/maven/plugin/project/install/ProjectInstallerTest.java
index 6a19faa..6007d21 100644
--- a/src/it/maven-project-installer-plugin/src/test/java/org/apache/maven/plugin/project/install/ProjectInstallerTest.java
+++ b/src/it/maven-project-installer-plugin/src/test/java/org/apache/maven/plugin/project/install/ProjectInstallerTest.java
@@ -151,8 +151,8 @@ public class ProjectInstallerTest
     {
         File jarClassifierFile = new File( baseDirectoy, baseArtifact + "-" + version + "-classifier.jar" );
         assertTrue( "jarClassifierFile '" + jarClassifierFile.getAbsolutePath() + "'", jarClassifierFile.exists() );
-        assertTrue( "jarClassifier md5 not found.", new File( jarClassifierFile.getAbsolutePath() + ".md5" ).exists() );
-        assertTrue( "jarClassifier sha1 not found.",
+        assertFalse( "jarClassifier md5 not found.", new File( jarClassifierFile.getAbsolutePath() + ".md5" ).exists() );
+        assertFalse( "jarClassifier sha1 not found.",
                     new File( jarClassifierFile.getAbsolutePath() + ".sha1" ).exists() );
     }
 
@@ -160,15 +160,15 @@ public class ProjectInstallerTest
     {
         File jarFile = new File( baseDirectoy, baseArtifact + "-" + version + ".jar" );
         assertTrue( "jarFile '" + jarFile.getAbsolutePath() + "'", jarFile.exists() );
-        assertTrue( "jar md5 not found.", new File( jarFile.getAbsolutePath() + ".md5" ).exists() );
-        assertTrue( "jar sha1 not found.", new File( jarFile.getAbsolutePath() + ".sha1" ).exists() );
+        assertFalse( "jar md5 not found.", new File( jarFile.getAbsolutePath() + ".md5" ).exists() );
+        assertFalse( "jar sha1 not found.", new File( jarFile.getAbsolutePath() + ".sha1" ).exists() );
     }
 
     private void checkForPomFile( File baseDirectoy, String baseArtifact, String version )
     {
-        File pomFile = new File( baseDirectoy, baseArtifact + "-" + version + ".pom" );
-        assertTrue( "pomFile not found. '" + pomFile.getAbsolutePath() + "'", pomFile.exists() );
-        assertTrue( "pom md5 not found.", new File( pomFile.getAbsolutePath() + ".md5" ).exists() );
-        assertTrue( "pom sha1 not found.", new File( pomFile.getAbsolutePath() + ".sha1" ).exists() );
+        File pomFile = new File( baseDirectoy, "maven-project-installer-plugin-it-1.0.0-A.pom" );
+        assertTrue( "pomFile '" + pomFile.getAbsolutePath() + "'", pomFile.exists() );
+        assertFalse( "pom md5 not found.", new File( pomFile.getAbsolutePath() + ".md5" ).exists() );
+        assertFalse( "pom sha1 not found.", new File( pomFile.getAbsolutePath() + ".sha1" ).exists() );
     }
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/maven/shared/project/install/internal/DefaultProjectInstaller.java b/src/main/java/org/apache/maven/shared/project/install/internal/DefaultProjectInstaller.java
index ceb17f4..4e001db 100644
--- a/src/main/java/org/apache/maven/shared/project/install/internal/DefaultProjectInstaller.java
+++ b/src/main/java/org/apache/maven/shared/project/install/internal/DefaultProjectInstaller.java
@@ -40,7 +40,6 @@ import org.apache.maven.shared.project.install.ProjectInstallerRequest;
 import org.apache.maven.shared.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;
 
@@ -62,8 +61,6 @@ class DefaultProjectInstaller
     @Requirement
     private RepositoryManager repositoryManager;
 
-    private final DualDigester digester = new DualDigester();
-
     /**
      * {@inheritDoc}
      */
@@ -75,8 +72,6 @@ class DefaultProjectInstaller
         validateParameters( buildingRequest, installerRequest );
         MavenProject project = installerRequest.getProject();
 
-        boolean createChecksum = true;
-        
         Artifact artifact = project.getArtifact();
         String packaging = project.getPackaging();
         File pomFile = project.getFile();
@@ -96,9 +91,7 @@ class DefaultProjectInstaller
             {
                 installer.install( buildingRequest,
                                    Collections.<Artifact>singletonList( new ProjectArtifact( project ) ) );
-                // The following call will add the .md5/sha1 to the pom itself.
-                installChecksums( buildingRequest, artifact, createChecksum );
-                addMetaDataFilesForArtifact( buildingRequest, artifact, metadataFiles, createChecksum );
+                addMetaDataFilesForArtifact( buildingRequest, artifact, metadataFiles );
             }
         }
         else
@@ -116,9 +109,7 @@ class DefaultProjectInstaller
             if ( file != null && file.isFile() )
             {
                 installer.install( buildingRequest, Collections.<Artifact>singletonList( artifact ) );
-                //This will add the checksums for the main artifact.
-                installChecksums( buildingRequest, artifact, createChecksum );
-                addMetaDataFilesForArtifact( buildingRequest, artifact, metadataFiles, createChecksum );
+                addMetaDataFilesForArtifact( buildingRequest, artifact, metadataFiles );
             }
             else if ( !attachedArtifacts.isEmpty() )
             {
@@ -136,11 +127,9 @@ class DefaultProjectInstaller
         for ( Artifact attached : attachedArtifacts )
         {
             installer.install( buildingRequest, Collections.singletonList( attached ) );
-            installChecksums( buildingRequest, attached, createChecksum );
-            addMetaDataFilesForArtifact( buildingRequest, attached, metadataFiles, createChecksum );
+            addMetaDataFilesForArtifact( buildingRequest, attached, metadataFiles );
         }
 
-        installChecksums( metadataFiles );
     }
 
     private void validateParameters( ProjectBuildingRequest buildingRequest, ProjectInstallerRequest installerRequest )
@@ -155,40 +144,11 @@ class DefaultProjectInstaller
         }
     }
 
-    /**
-     * Installs the checksums for the specified artifact if this has been enabled in the plugin configuration. This
-     * method creates checksums for files that have already been installed to the local repo to account for on-the-fly
-     * generated/updated files. For example, in Maven 2.0.4- the <code>ProjectArtifactMetadata</code> did not install
-     * the original POM file (cf. MNG-2820). While the plugin currently requires Maven 2.0.6, we continue to hash the
-     * installed POM for robustness with regard to future changes like re-introducing some kind of POM filtering.
-     *
-     * @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>.
-     * @param createChecksum {@code true} if checksum should be created, otherwise {@code false}.
-     * @throws IOException If the checksums could not be installed.
-     */
-    private void installChecksums( ProjectBuildingRequest buildingRequest, Artifact artifact, boolean createChecksum )
-        throws IOException
-    {
-        if ( !createChecksum )
-        {
-            return;
-        }
-
-        File artifactFile = getLocalRepoFile( buildingRequest, artifact );
-        installChecksums( artifactFile );
-    }
-
     // CHECKSTYLE_OFF: LineLength
     private void addMetaDataFilesForArtifact( ProjectBuildingRequest buildingRequest, Artifact artifact,
-                                              Collection<File> targetMetadataFiles, boolean createChecksum )
+                                              Collection<File> targetMetadataFiles )
     // CHECKSTYLE_ON: LineLength
     {
-        if ( !createChecksum )
-        {
-            return;
-        }
-
         Collection<ArtifactMetadata> metadatas = artifact.getMetadataList();
         if ( metadatas != null )
         {
@@ -201,82 +161,6 @@ class DefaultProjectInstaller
     }
 
     /**
-     * Installs the checksums for the specified metadata files.
-     *
-     * @param metadataFiles The collection of metadata files to install checksums for, must not be <code>null</code>.
-     * @throws IOException If the checksums could not be installed.
-     */
-    private void installChecksums( Collection<File> metadataFiles )
-        throws IOException
-    {
-        for ( File metadataFile : metadataFiles )
-        {
-            installChecksums( metadataFile );
-        }
-    }
-
-    /**
-     * 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 );
-    }
-
-    /**
      * Gets the path of the specified artifact metadata within the local repository. Note that the returned path need
      * not exist (yet).
      *
diff --git a/src/main/java/org/apache/maven/shared/project/install/internal/DualDigester.java b/src/main/java/org/apache/maven/shared/project/install/internal/DualDigester.java
deleted file mode 100644
index 000bf65..0000000
--- a/src/main/java/org/apache/maven/shared/project/install/internal/DualDigester.java
+++ /dev/null
@@ -1,115 +0,0 @@
-package org.apache.maven.shared.project.install.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 );
-        }
-    }
-}
diff --git a/src/test/java/org/apache/maven/shared/project/install/internal/DualDigesterTest.java b/src/test/java/org/apache/maven/shared/project/deploy/internal/DualDigesterTest.java
similarity index 95%
rename from src/test/java/org/apache/maven/shared/project/install/internal/DualDigesterTest.java
rename to src/test/java/org/apache/maven/shared/project/deploy/internal/DualDigesterTest.java
index 7f8fbe8..49b7698 100644
--- a/src/test/java/org/apache/maven/shared/project/install/internal/DualDigesterTest.java
+++ b/src/test/java/org/apache/maven/shared/project/deploy/internal/DualDigesterTest.java
@@ -1,4 +1,4 @@
-package org.apache.maven.shared.project.install.internal;
+package org.apache.maven.shared.project.deploy.internal;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one


[maven-artifact-transfer] 03/12: [MSHARED-695] - WIP - Move checksum generation from install to deploy

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

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

commit 055fece31a079bd4bc9f2b696327eb8d5dd7aa50
Author: Karl Heinz Marbaise <kh...@apache.org>
AuthorDate: Sun Apr 1 16:54:48 2018 +0200

    [MSHARED-695] - WIP - Move checksum generation from install to deploy
---
 .../project/install/internal/DualDigesterTest.java  | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/src/test/java/org/apache/maven/shared/project/install/internal/DualDigesterTest.java b/src/test/java/org/apache/maven/shared/project/install/internal/DualDigesterTest.java
index 38da15b..7f8fbe8 100644
--- a/src/test/java/org/apache/maven/shared/project/install/internal/DualDigesterTest.java
+++ b/src/test/java/org/apache/maven/shared/project/install/internal/DualDigesterTest.java
@@ -1,5 +1,24 @@
 package org.apache.maven.shared.project.install.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.InputStream;
 
 import org.junit.Test;
@@ -19,7 +38,7 @@ public class DualDigesterTest
         
         DualDigester dd = new DualDigester();
         
-        dd.calculate( file );
+//        dd.calculate( file );
     }
     
 }


[maven-artifact-transfer] 12/12: [MSHARED-695] - WIP - Move checksum generation from install to deploy o Continued.

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

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

commit cf55484f08ae39c92582dbb2a09c0162108dd345
Author: Karl Heinz Marbaise <kh...@apache.org>
AuthorDate: Sun Jun 24 23:04:11 2018 +0200

    [MSHARED-695] - WIP - Move checksum generation from install to deploy
     o Continued.
---
 .../plugin/project/install/ProjectInstallerTest.java     | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/it/maven-project-installer-plugin/src/test/java/org/apache/maven/plugin/project/install/ProjectInstallerTest.java b/src/it/maven-project-installer-plugin/src/test/java/org/apache/maven/plugin/project/install/ProjectInstallerTest.java
index cb47067..316b26e 100644
--- a/src/it/maven-project-installer-plugin/src/test/java/org/apache/maven/plugin/project/install/ProjectInstallerTest.java
+++ b/src/it/maven-project-installer-plugin/src/test/java/org/apache/maven/plugin/project/install/ProjectInstallerTest.java
@@ -141,8 +141,8 @@ public class ProjectInstallerTest
                       "PROJECT-INSTALLER-GROUPID-701-" + mvnVersion + "maven-project-installer-project-701/2.0.701/" );
 
         checkForPomFile( baseDirectoy, "maven-project-installer-project-701", "2.0.701" );
-
-        checkForJarFile( baseDirectoy, "maven-project-installer-project-701", "2.0.701" );
+        
+        checkForNonExistingJarFile( baseDirectoy, "maven-project-installer-project-701", "2.0.701" );
 
         checkForJarClassifierFile( baseDirectoy, "maven-project-installer-project-701", "2.0.701" );
 
@@ -167,9 +167,19 @@ public class ProjectInstallerTest
 
     private void checkForPomFile( File baseDirectoy, String baseArtifact, String version )
     {
-        File pomFile = new File( baseDirectoy, "maven-project-installer-plugin-it-1.0.0-A.pom" );
+        File pomFile = new File( baseDirectoy, baseArtifact + "-" + version + ".pom" );
         assertTrue( "pomFile '" + pomFile.getAbsolutePath() + "'", pomFile.exists() );
         assertFalse( "pom md5 not found.", new File( pomFile.getAbsolutePath() + ".md5" ).exists() );
         assertFalse( "pom sha1 not found.", new File( pomFile.getAbsolutePath() + ".sha1" ).exists() );
     }
+
+    private void checkForNonExistingJarFile( File baseDirectoy, String baseArtifact, String version )
+    {
+        File jarFile = new File( baseDirectoy, baseArtifact + "-" + version + ".jar" );
+        assertFalse( "jarFile '" + jarFile.getAbsolutePath() + "'", jarFile.exists() );
+        assertFalse( "jar md5 not found.", new File( jarFile.getAbsolutePath() + ".md5" ).exists() );
+        assertFalse( "jar sha1 not found.", new File( jarFile.getAbsolutePath() + ".sha1" ).exists() );
+    }
+
+    
 }


[maven-artifact-transfer] 04/12: [MSHARED-695] - WIP - Move checksum generation from install to deploy

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

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

commit f0e696808f264341ae3153f7b74be2f0b3286a8f
Author: Karl Heinz Marbaise <kh...@apache.org>
AuthorDate: Sun Apr 8 20:32:33 2018 +0200

    [MSHARED-695] - WIP - Move checksum generation from install to deploy
---
 .../deploy/internal/DefaultProjectDeployer.java    | 72 +++++++++++++++++-----
 1 file changed, 55 insertions(+), 17 deletions(-)

diff --git a/src/main/java/org/apache/maven/shared/project/deploy/internal/DefaultProjectDeployer.java b/src/main/java/org/apache/maven/shared/project/deploy/internal/DefaultProjectDeployer.java
index ca51ccc..e1af430 100644
--- a/src/main/java/org/apache/maven/shared/project/deploy/internal/DefaultProjectDeployer.java
+++ b/src/main/java/org/apache/maven/shared/project/deploy/internal/DefaultProjectDeployer.java
@@ -26,6 +26,7 @@ import java.util.Collection;
 import java.util.List;
 
 import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.metadata.ArtifactMetadata;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.project.ProjectBuildingRequest;
 import org.apache.maven.project.artifact.ProjectArtifactMetadata;
@@ -34,6 +35,7 @@ import org.apache.maven.shared.artifact.deploy.ArtifactDeployerException;
 import org.apache.maven.shared.project.NoFileAssignedException;
 import org.apache.maven.shared.project.deploy.ProjectDeployer;
 import org.apache.maven.shared.project.deploy.ProjectDeployerRequest;
+import org.apache.maven.shared.repository.RepositoryManager;
 import org.codehaus.plexus.component.annotations.Component;
 import org.codehaus.plexus.component.annotations.Requirement;
 import org.codehaus.plexus.util.FileUtils;
@@ -55,6 +57,9 @@ class DefaultProjectDeployer
     @Requirement
     private ArtifactDeployer deployer;
 
+    @Requirement
+    private RepositoryManager repositoryManager;
+
     private final DualDigester digester = new DualDigester();
 
     /**
@@ -104,9 +109,8 @@ class DefaultProjectDeployer
 
             if ( file != null && file.isFile() )
             {
-//                installChecksums( buildingRequest, artifact, createChecksum );
-                // ?
                 deployableArtifacts.add( artifact );
+                // installChecksums( buildingRequest, artifact, createChecksum );
             }
             else if ( !attachedArtifacts.isEmpty() )
             {
@@ -124,10 +128,11 @@ class DefaultProjectDeployer
 
         for ( Artifact attached : attachedArtifacts )
         {
-//            installChecksums( buildingRequest, artifact, createChecksum );
+            // installChecksums( buildingRequest, artifact, createChecksum );
             deployableArtifacts.add( attached );
         }
 
+        installChecksumsForAllArtifacts( buildingRequest, deployableArtifacts );
         deploy( buildingRequest, deployableArtifacts, artifactRepository, retryFailedDeploymentCount );
     }
 
@@ -149,6 +154,22 @@ class DefaultProjectDeployer
         }
     }
 
+    private void installChecksumsForAllArtifacts( ProjectBuildingRequest request, Collection<Artifact> artifacts )
+    {
+        for ( Artifact item : artifacts )
+        {
+            try
+            {
+                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
@@ -191,27 +212,16 @@ class DefaultProjectDeployer
     }
 
     /**
-     * Installs the checksums for the specified artifact if this has been enabled in the plugin configuration. This
-     * method creates checksums for files that have already been installed to the local repo to account for on-the-fly
-     * generated/updated files. For example, in Maven 2.0.4- the <code>ProjectArtifactMetadata</code> did not install
-     * the original POM file (cf. MNG-2820). While the plugin currently requires Maven 2.0.6, we continue to hash the
-     * installed POM for robustness with regard to future changes like re-introducing some kind of POM filtering.
-     *
      * @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>.
      * @param createChecksum {@code true} if checksum should be created, otherwise {@code false}.
      * @throws IOException If the checksums could not be installed.
      */
-    private void installChecksums( ProjectBuildingRequest buildingRequest, Artifact artifact, boolean createChecksum )
+    private void installChecksums( ProjectBuildingRequest buildingRequest, Artifact artifact )
         throws IOException
     {
-        if ( !createChecksum )
-        {
-            return;
-        }
-
-//        File artifactFile = getLocalRepoFile( buildingRequest, artifact );
-//        installChecksums( artifactFile );
+        File artifactFile = getLocalRepoFile( buildingRequest, artifact );
+        installChecksums( artifactFile );
     }
 
     /**
@@ -276,4 +286,32 @@ class DefaultProjectDeployer
         }
     }
 
+    /**
+     * 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 );
+    }
+
+    /**
+     * Gets the path of the specified artifact metadata 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 metadata The artifact metadata whose local repo path should be determined, must not be <code>null</code>.
+     * @return The absolute path to the artifact metadata when installed, never <code>null</code>.
+     */
+    private File getLocalRepoFile( ProjectBuildingRequest buildingRequest, ArtifactMetadata metadata )
+    {
+        String path = repositoryManager.getPathForLocalMetadata( buildingRequest, metadata );
+        return new File( repositoryManager.getLocalRepositoryBasedir( buildingRequest ), path );
+    }
+
 }


[maven-artifact-transfer] 07/12: [MSHARED-695] - WIP - Move checksum generation from install to deploy o Moved checksum generation into deploy part. Removed checksum from install. o Removed it from ProjectInstallerRequest.

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

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

commit 8511ea161dbcbd3d28ffbd22ed00d6a192144a75
Author: Karl Heinz Marbaise <kh...@apache.org>
AuthorDate: Sun Apr 15 18:59:47 2018 +0200

    [MSHARED-695] - WIP - Move checksum generation from install to deploy
     o Moved checksum generation into deploy part. Removed checksum from
       install.
     o Removed it from ProjectInstallerRequest.
---
 .../shared/project/install/ProjectInstaller.java   |  4 +---
 .../project/install/ProjectInstallerRequest.java   | 22 ----------------------
 2 files changed, 1 insertion(+), 25 deletions(-)

diff --git a/src/main/java/org/apache/maven/shared/project/install/ProjectInstaller.java b/src/main/java/org/apache/maven/shared/project/install/ProjectInstaller.java
index 0fab22e..0b2376c 100644
--- a/src/main/java/org/apache/maven/shared/project/install/ProjectInstaller.java
+++ b/src/main/java/org/apache/maven/shared/project/install/ProjectInstaller.java
@@ -47,9 +47,7 @@ public interface ProjectInstaller
      *  
      *    ProjectInstallerRequest pir =
      *      new ProjectInstallerRequest()
-     *         .setProject( mavenProject )
-     *         .setCreateChecksum( false )
-     *         .setUpdateReleaseInfo( false );
+     *         .setProject( mavenProject );
      *  
      *  installer.install( session.getProjectBuildingRequest(), pir );
      * </pre>
diff --git a/src/main/java/org/apache/maven/shared/project/install/ProjectInstallerRequest.java b/src/main/java/org/apache/maven/shared/project/install/ProjectInstallerRequest.java
index 6a9505f..d33abbb 100644
--- a/src/main/java/org/apache/maven/shared/project/install/ProjectInstallerRequest.java
+++ b/src/main/java/org/apache/maven/shared/project/install/ProjectInstallerRequest.java
@@ -26,33 +26,11 @@ import org.apache.maven.project.MavenProject;
  */
 public class ProjectInstallerRequest
 {
-    // From AbstractInstallMojo
-
-    private boolean createChecksum;
-
     // From InstallMojo
 
     private MavenProject project;
 
     /**
-     * @return the createChecksum
-     */
-    public boolean isCreateChecksum()
-    {
-        return createChecksum;
-    }
-
-    /**
-     * @param theCreateChecksumToBeSet the createChecksum to set
-     * @return {@link ProjectInstallerRequest} for chaining.
-     */
-    public ProjectInstallerRequest setCreateChecksum( boolean theCreateChecksumToBeSet )
-    {
-        this.createChecksum = theCreateChecksumToBeSet;
-        return this;
-    }
-
-    /**
      * @return the project
      */
     public MavenProject getProject()


[maven-artifact-transfer] 10/12: Make special version for the branch.

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

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

commit ad8e322a47d84e66bf22fb00ddfa54bcf6acd7b7
Author: Karl Heinz Marbaise <kh...@apache.org>
AuthorDate: Wed May 2 17:54:45 2018 +0200

    Make special version for the branch.
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 1a87da2..e467851 100644
--- a/pom.xml
+++ b/pom.xml
@@ -30,7 +30,7 @@
   </parent>
 
   <artifactId>maven-artifact-transfer</artifactId>
-  <version>0.9.2-SNAPSHOT</version>
+  <version>0.10.0.MSHARED695-SNAPSHOT</version>
 
   <name>Apache Maven Artifact Transfer</name>
   <description>An API to install, deploy and resolving artifacts with Maven 3</description>


[maven-artifact-transfer] 02/12: [MSHARED-695] - WIP - Move checksum generation from install to deploy

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

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

commit e9462a623f2097c46b8d986d299ccdf64dd113fa
Author: Karl Heinz Marbaise <kh...@apache.org>
AuthorDate: Sat Mar 31 10:37:00 2018 +0200

    [MSHARED-695] - WIP - Move checksum generation from install to deploy
---
 .../project/deploy/ProjectDeployerRequest.java     |  22 ----
 .../deploy/internal/DefaultProjectDeployer.java    | 104 +++++++++++++++++--
 .../project/deploy/internal/DualDigester.java      | 115 +++++++++++++++++++++
 .../project/install/ProjectInstallerRequest.java   |  20 ----
 .../install/internal/DefaultProjectInstaller.java  |  10 +-
 .../project/install/internal/DualDigesterTest.java |  25 +++++
 src/test/resources/test.jar                        |   1 +
 7 files changed, 241 insertions(+), 56 deletions(-)

diff --git a/src/main/java/org/apache/maven/shared/project/deploy/ProjectDeployerRequest.java b/src/main/java/org/apache/maven/shared/project/deploy/ProjectDeployerRequest.java
index 3f98471..3a50c18 100644
--- a/src/main/java/org/apache/maven/shared/project/deploy/ProjectDeployerRequest.java
+++ b/src/main/java/org/apache/maven/shared/project/deploy/ProjectDeployerRequest.java
@@ -28,10 +28,6 @@ import org.apache.maven.project.MavenProject;
 public class ProjectDeployerRequest
 {
 
-    // From AbstractDeployMojo
-
-    private boolean updateReleaseInfo;
-
     private int retryFailedDeploymentCount;
 
     // From DeployMojo
@@ -45,24 +41,6 @@ public class ProjectDeployerRequest
     private String altReleaseDeploymentRepository;
 
     /**
-     * @return the updateReleaseInfo
-     */
-    public boolean isUpdateReleaseInfo()
-    {
-        return updateReleaseInfo;
-    }
-
-    /**
-     * @param theUpdateReleaseInfoToBeSet the updateReleaseInfo to set
-     * @return {@link ProjectDeployerRequest} for chaining.
-     */
-    public ProjectDeployerRequest setUpdateReleaseInfo( boolean theUpdateReleaseInfoToBeSet )
-    {
-        this.updateReleaseInfo = theUpdateReleaseInfoToBeSet;
-        return this;
-    }
-
-    /**
      * @return the retryFailedDeploymentCount
      */
     public int getRetryFailedDeploymentCount()
diff --git a/src/main/java/org/apache/maven/shared/project/deploy/internal/DefaultProjectDeployer.java b/src/main/java/org/apache/maven/shared/project/deploy/internal/DefaultProjectDeployer.java
index 74049be..ca51ccc 100644
--- a/src/main/java/org/apache/maven/shared/project/deploy/internal/DefaultProjectDeployer.java
+++ b/src/main/java/org/apache/maven/shared/project/deploy/internal/DefaultProjectDeployer.java
@@ -20,6 +20,7 @@ package org.apache.maven.shared.project.deploy.internal;
  */
 
 import java.io.File;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
@@ -35,6 +36,7 @@ import org.apache.maven.shared.project.deploy.ProjectDeployer;
 import org.apache.maven.shared.project.deploy.ProjectDeployerRequest;
 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;
 
@@ -53,6 +55,8 @@ class DefaultProjectDeployer
     @Requirement
     private ArtifactDeployer deployer;
 
+    private final DualDigester digester = new DualDigester();
+
     /**
      * {@inheritDoc}
      */
@@ -60,6 +64,8 @@ class DefaultProjectDeployer
                         ArtifactRepository artifactRepository )
         throws NoFileAssignedException, IllegalArgumentException, ArtifactDeployerException
     {
+        boolean createChecksum = true;
+
         validateParameters( buildingRequest, projectDeployerRequest, artifactRepository );
 
         Artifact artifact = projectDeployerRequest.getProject().getArtifact();
@@ -80,13 +86,8 @@ class DefaultProjectDeployer
             artifact.addMetadata( metadata );
         }
 
-        // FIXME: It does not make sense to set an artifact explicitly to a "Release"
-        // cause this should be choosen only by the not existing of "-SNAPSHOT" in the
-        // version.
-        if ( projectDeployerRequest.isUpdateReleaseInfo() )
-        {
-            artifact.setRelease( true );
-        }
+        // What consequence does this have?
+        // artifact.setRelease( true );
 
         artifact.setRepository( artifactRepository );
 
@@ -103,6 +104,8 @@ class DefaultProjectDeployer
 
             if ( file != null && file.isFile() )
             {
+//                installChecksums( buildingRequest, artifact, createChecksum );
+                // ?
                 deployableArtifacts.add( artifact );
             }
             else if ( !attachedArtifacts.isEmpty() )
@@ -121,6 +124,7 @@ class DefaultProjectDeployer
 
         for ( Artifact attached : attachedArtifacts )
         {
+//            installChecksums( buildingRequest, artifact, createChecksum );
             deployableArtifacts.add( attached );
         }
 
@@ -186,4 +190,90 @@ class DefaultProjectDeployer
         }
     }
 
+    /**
+     * Installs the checksums for the specified artifact if this has been enabled in the plugin configuration. This
+     * method creates checksums for files that have already been installed to the local repo to account for on-the-fly
+     * generated/updated files. For example, in Maven 2.0.4- the <code>ProjectArtifactMetadata</code> did not install
+     * the original POM file (cf. MNG-2820). While the plugin currently requires Maven 2.0.6, we continue to hash the
+     * installed POM for robustness with regard to future changes like re-introducing some kind of POM filtering.
+     *
+     * @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>.
+     * @param createChecksum {@code true} if checksum should be created, otherwise {@code false}.
+     * @throws IOException If the checksums could not be installed.
+     */
+    private void installChecksums( ProjectBuildingRequest buildingRequest, Artifact artifact, boolean createChecksum )
+        throws IOException
+    {
+        if ( !createChecksum )
+        {
+            return;
+        }
+
+//        File artifactFile = getLocalRepoFile( buildingRequest, artifact );
+//        installChecksums( artifactFile );
+    }
+
+    /**
+     * Installs the checksums for the specified metadata files.
+     *
+     * @param metadataFiles The collection of metadata files to install checksums for, must not be <code>null</code>.
+     * @throws IOException If the checksums could not be installed.
+     */
+    private void installChecksums( Collection<File> metadataFiles )
+        throws IOException
+    {
+        for ( File metadataFile : metadataFiles )
+        {
+            installChecksums( metadataFile );
+        }
+    }
+
+    /**
+     * 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 );
+        }
+    }
+
 }
diff --git a/src/main/java/org/apache/maven/shared/project/deploy/internal/DualDigester.java b/src/main/java/org/apache/maven/shared/project/deploy/internal/DualDigester.java
new file mode 100644
index 0000000..a2b8c34
--- /dev/null
+++ b/src/main/java/org/apache/maven/shared/project/deploy/internal/DualDigester.java
@@ -0,0 +1,115 @@
+package org.apache.maven.shared.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 );
+        }
+    }
+}
diff --git a/src/main/java/org/apache/maven/shared/project/install/ProjectInstallerRequest.java b/src/main/java/org/apache/maven/shared/project/install/ProjectInstallerRequest.java
index c37329b..6a9505f 100644
--- a/src/main/java/org/apache/maven/shared/project/install/ProjectInstallerRequest.java
+++ b/src/main/java/org/apache/maven/shared/project/install/ProjectInstallerRequest.java
@@ -30,8 +30,6 @@ public class ProjectInstallerRequest
 
     private boolean createChecksum;
 
-    private boolean updateReleaseInfo;
-
     // From InstallMojo
 
     private MavenProject project;
@@ -55,24 +53,6 @@ public class ProjectInstallerRequest
     }
 
     /**
-     * @return the updateReleaseInfo
-     */
-    public boolean isUpdateReleaseInfo()
-    {
-        return updateReleaseInfo;
-    }
-
-    /**
-     * @param theUpdateReleaseInfoToBeSet the updateReleaseInfo to set
-     * @return {@link ProjectInstallerRequest} for chaining.
-     */
-    public ProjectInstallerRequest setUpdateReleaseInfo( boolean theUpdateReleaseInfoToBeSet )
-    {
-        this.updateReleaseInfo = theUpdateReleaseInfoToBeSet;
-        return this;
-    }
-
-    /**
      * @return the project
      */
     public MavenProject getProject()
diff --git a/src/main/java/org/apache/maven/shared/project/install/internal/DefaultProjectInstaller.java b/src/main/java/org/apache/maven/shared/project/install/internal/DefaultProjectInstaller.java
index f0ee602..ceb17f4 100644
--- a/src/main/java/org/apache/maven/shared/project/install/internal/DefaultProjectInstaller.java
+++ b/src/main/java/org/apache/maven/shared/project/install/internal/DefaultProjectInstaller.java
@@ -71,11 +71,12 @@ class DefaultProjectInstaller
     public void install( ProjectBuildingRequest buildingRequest, ProjectInstallerRequest installerRequest )
         throws IOException, ArtifactInstallerException, NoFileAssignedException, IllegalArgumentException
     {
+
         validateParameters( buildingRequest, installerRequest );
         MavenProject project = installerRequest.getProject();
-        boolean createChecksum = installerRequest.isCreateChecksum();
-        boolean updateReleaseInfo = installerRequest.isUpdateReleaseInfo();
 
+        boolean createChecksum = true;
+        
         Artifact artifact = project.getArtifact();
         String packaging = project.getPackaging();
         File pomFile = project.getFile();
@@ -87,11 +88,6 @@ class DefaultProjectInstaller
 
         ProjectArtifactMetadata metadata;
 
-        if ( updateReleaseInfo )
-        {
-            artifact.setRelease( true );
-        }
-
         Collection<File> metadataFiles = new LinkedHashSet<File>();
 
         if ( isPomArtifact )
diff --git a/src/test/java/org/apache/maven/shared/project/install/internal/DualDigesterTest.java b/src/test/java/org/apache/maven/shared/project/install/internal/DualDigesterTest.java
new file mode 100644
index 0000000..38da15b
--- /dev/null
+++ b/src/test/java/org/apache/maven/shared/project/install/internal/DualDigesterTest.java
@@ -0,0 +1,25 @@
+package org.apache.maven.shared.project.install.internal;
+
+import java.io.InputStream;
+
+import org.junit.Test;
+
+public class DualDigesterTest
+{
+
+    enum ChecksumTypes {
+        MD5,
+        SHA1,
+        SHA256
+    }
+    @Test
+    public void testName()
+    {
+        InputStream resourceAsStream = this.getClass().getResourceAsStream( "/test.jar" );
+        
+        DualDigester dd = new DualDigester();
+        
+        dd.calculate( file );
+    }
+    
+}
diff --git a/src/test/resources/test.jar b/src/test/resources/test.jar
new file mode 100644
index 0000000..71d030c
--- /dev/null
+++ b/src/test/resources/test.jar
@@ -0,0 +1 @@
+This is a Test File


[maven-artifact-transfer] 11/12: [MSHARED-695] - WIP - Move checksum generation from install to deploy o Continued.

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

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

commit 46ae245f5107fb7e7c89cd140ee5c2f3e1c02f25
Author: Karl Heinz Marbaise <kh...@apache.org>
AuthorDate: Mon May 28 19:23:11 2018 +0200

    [MSHARED-695] - WIP - Move checksum generation from install to deploy
     o Continued.
---
 src/it/maven-project-deployer-plugin/pom.xml                            | 2 +-
 src/it/maven-project-installer-plugin/pom.xml                           | 2 +-
 .../org/apache/maven/plugin/project/install/ProjectInstallerMojo.java   | 1 -
 .../org/apache/maven/plugin/project/install/ProjectInstallerTest.java   | 1 +
 .../maven/shared/project/deploy/internal/DefaultProjectDeployer.java    | 1 +
 5 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/it/maven-project-deployer-plugin/pom.xml b/src/it/maven-project-deployer-plugin/pom.xml
index baeecc8..e66bd7a 100644
--- a/src/it/maven-project-deployer-plugin/pom.xml
+++ b/src/it/maven-project-deployer-plugin/pom.xml
@@ -63,7 +63,7 @@
       <groupId>org.apache.maven.shared</groupId>
       <artifactId>maven-artifact-transfer</artifactId>
       <version>@project.version@</version>
-<!--       <version>0.9.2-SNAPSHOT</version> -->
+<!--       <version>0.10.0.MSHARED695-SNAPSHOT</version> -->
     </dependency>
 
     <!-- dependencies to annotations -->
diff --git a/src/it/maven-project-installer-plugin/pom.xml b/src/it/maven-project-installer-plugin/pom.xml
index f0e0fbd..360a954 100644
--- a/src/it/maven-project-installer-plugin/pom.xml
+++ b/src/it/maven-project-installer-plugin/pom.xml
@@ -63,7 +63,7 @@
       <groupId>org.apache.maven.shared</groupId>
       <artifactId>maven-artifact-transfer</artifactId>
       <version>@project.version@</version>
-<!--       <version>0.9.2-SNAPSHOT</version> -->
+<!-- <version>0.10.0.MSHARED695-SNAPSHOT</version> -->
     </dependency>
 
     <!-- dependencies to annotations -->
diff --git a/src/it/maven-project-installer-plugin/src/main/java/org/apache/maven/plugin/project/install/ProjectInstallerMojo.java b/src/it/maven-project-installer-plugin/src/main/java/org/apache/maven/plugin/project/install/ProjectInstallerMojo.java
index 24a57be..706dfd0 100644
--- a/src/it/maven-project-installer-plugin/src/main/java/org/apache/maven/plugin/project/install/ProjectInstallerMojo.java
+++ b/src/it/maven-project-installer-plugin/src/main/java/org/apache/maven/plugin/project/install/ProjectInstallerMojo.java
@@ -107,7 +107,6 @@ public class ProjectInstallerMojo
             session.getCurrentProject().getArtifact().setFile( tmpFile );
             
             ProjectInstallerRequest pir = new ProjectInstallerRequest();
-            pir.setCreateChecksum( true );
             pir.setProject( session.getCurrentProject());
             installer.install( pbr, pir );
         }
diff --git a/src/it/maven-project-installer-plugin/src/test/java/org/apache/maven/plugin/project/install/ProjectInstallerTest.java b/src/it/maven-project-installer-plugin/src/test/java/org/apache/maven/plugin/project/install/ProjectInstallerTest.java
index 6007d21..cb47067 100644
--- a/src/it/maven-project-installer-plugin/src/test/java/org/apache/maven/plugin/project/install/ProjectInstallerTest.java
+++ b/src/it/maven-project-installer-plugin/src/test/java/org/apache/maven/plugin/project/install/ProjectInstallerTest.java
@@ -20,6 +20,7 @@ package org.apache.maven.plugin.project.install;
  */
 
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
 
 import java.io.File;
 
diff --git a/src/main/java/org/apache/maven/shared/project/deploy/internal/DefaultProjectDeployer.java b/src/main/java/org/apache/maven/shared/project/deploy/internal/DefaultProjectDeployer.java
index be95dd7..01bc1a0 100644
--- a/src/main/java/org/apache/maven/shared/project/deploy/internal/DefaultProjectDeployer.java
+++ b/src/main/java/org/apache/maven/shared/project/deploy/internal/DefaultProjectDeployer.java
@@ -158,6 +158,7 @@ class DefaultProjectDeployer
         {
             try
             {
+                LOGGER.debug( "Installing checksum for " + item.getId() );
                 installChecksums( request, item );
             }
             catch ( IOException e )