[MSHARED-695] - Move checksum generation from install to deploy
o Moved checksum generation into deploy part. Removed checksum from
install
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" ] )
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>
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-deployer-plugin/src/test/java/org/apache/maven/plugin/artifact/deployer/ArtifactDeployerTest.java b/src/it/maven-artifact-deployer-plugin/src/test/java/org/apache/maven/plugin/artifact/deployer/ArtifactDeployerTest.java
index 1452adc..6fcb201 100644
--- a/src/it/maven-artifact-deployer-plugin/src/test/java/org/apache/maven/plugin/artifact/deployer/ArtifactDeployerTest.java
+++ b/src/it/maven-artifact-deployer-plugin/src/test/java/org/apache/maven/plugin/artifact/deployer/ArtifactDeployerTest.java
@@ -43,7 +43,7 @@
* @author Karl Heinz Marbaise
*/
@RunWith( MavenJUnitTestRunner.class )
-@MavenVersions( { "3.0.5", "3.1.1", "3.2.5", "3.3.1", "3.3.9", "3.5.0", "3.5.2", "3.5.3" } )
+@MavenVersions( { "3.0.5", "3.1.1", "3.2.5", "3.3.1", "3.3.9", "3.5.0", "3.5.2", "3.5.3", "3.5.4" } )
public class ArtifactDeployerTest
{
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-artifact-installer-plugin/src/test/java/org/apache/maven/plugin/artifact/installer/ArtifactInstallerTest.java b/src/it/maven-artifact-installer-plugin/src/test/java/org/apache/maven/plugin/artifact/installer/ArtifactInstallerTest.java
index 67903ea..a48c51c 100644
--- a/src/it/maven-artifact-installer-plugin/src/test/java/org/apache/maven/plugin/artifact/installer/ArtifactInstallerTest.java
+++ b/src/it/maven-artifact-installer-plugin/src/test/java/org/apache/maven/plugin/artifact/installer/ArtifactInstallerTest.java
@@ -44,7 +44,7 @@
* @author Karl Heinz Marbaise
*/
@RunWith( MavenJUnitTestRunner.class )
-@MavenVersions( { "3.0.5", "3.1.1", "3.2.5", "3.3.1", "3.3.9", "3.5.0", "3.5.2", "3.5.3" } )
+@MavenVersions( { "3.0.5", "3.1.1", "3.2.5", "3.3.1", "3.3.9", "3.5.0", "3.5.2", "3.5.3", "3.5.4" } )
public class ArtifactInstallerTest
{
diff --git a/src/it/maven-project-deployer-plugin/pom.xml b/src/it/maven-project-deployer-plugin/pom.xml
index d6eaa8f..e66bd7a 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>
@@ -62,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-deployer-plugin/src/test/java/org/apache/maven/plugin/project/deploy/ProjectDeployerTest.java b/src/it/maven-project-deployer-plugin/src/test/java/org/apache/maven/plugin/project/deploy/ProjectDeployerTest.java
index 935e5c5..d5fc34d 100644
--- a/src/it/maven-project-deployer-plugin/src/test/java/org/apache/maven/plugin/project/deploy/ProjectDeployerTest.java
+++ b/src/it/maven-project-deployer-plugin/src/test/java/org/apache/maven/plugin/project/deploy/ProjectDeployerTest.java
@@ -42,7 +42,7 @@
* @author Karl Heinz Marbaise
*/
@RunWith( MavenJUnitTestRunner.class )
-@MavenVersions( { "3.0.5", "3.1.1", "3.2.5", "3.3.1", "3.3.9", "3.5.0", "3.5.2", "3.5.3" } )
+@MavenVersions( { "3.0.5", "3.1.1", "3.2.5", "3.3.1", "3.3.9", "3.5.0", "3.5.2", "3.5.3", "3.5.4" } )
public class ProjectDeployerTest
{
diff --git a/src/it/maven-project-installer-plugin/pom.xml b/src/it/maven-project-installer-plugin/pom.xml
index 5d68af9..360a954 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>
@@ -62,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 @@
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 6a19faa..ca57a2b 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 @@
*/
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
import java.io.File;
@@ -42,7 +43,7 @@
* @author Karl Heinz Marbaise
*/
@RunWith( MavenJUnitTestRunner.class )
-@MavenVersions( { "3.1.1", "3.2.5", "3.3.1", "3.3.9", "3.5.0", "3.5.2", "3.5.3" } )
+@MavenVersions( { "3.1.1", "3.2.5", "3.3.1", "3.3.9", "3.5.0", "3.5.2", "3.5.3", "3.5.4" } )
public class ProjectInstallerTest
{
@@ -140,8 +141,8 @@
"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" );
@@ -151,8 +152,8 @@
{
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 +161,25 @@
{
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() );
+ 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
+
+ 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() );
+ }
+
+
+}
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 @@
public class ProjectDeployerRequest
{
- // From AbstractDeployMojo
-
- private boolean updateReleaseInfo;
-
private int retryFailedDeploymentCount;
// From DeployMojo
@@ -45,24 +41,6 @@
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..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
@@ -20,11 +20,13 @@
*/
import java.io.File;
+import java.io.IOException;
import java.util.ArrayList;
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;
@@ -33,8 +35,10 @@
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;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -53,6 +57,11 @@
@Requirement
private ArtifactDeployer deployer;
+ @Requirement
+ private RepositoryManager repositoryManager;
+
+ private final DualDigester digester = new DualDigester();
+
/**
* {@inheritDoc}
*/
@@ -80,13 +89,8 @@
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 );
@@ -104,6 +108,7 @@
if ( file != null && file.isFile() )
{
deployableArtifacts.add( artifact );
+ // installChecksums( buildingRequest, artifact, createChecksum );
}
else if ( !attachedArtifacts.isEmpty() )
{
@@ -121,9 +126,11 @@
for ( Artifact attached : attachedArtifacts )
{
+ // installChecksums( buildingRequest, artifact, createChecksum );
deployableArtifacts.add( attached );
}
+ installChecksumsForAllArtifacts( buildingRequest, deployableArtifacts );
deploy( buildingRequest, deployableArtifacts, artifactRepository, retryFailedDeploymentCount );
}
@@ -145,6 +152,23 @@
}
}
+ 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
@@ -186,4 +210,107 @@
}
}
+ /**
+ * @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 )
+ throws IOException
+ {
+ 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 );
+ }
+ }
+
+ /**
+ * 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 );
+ }
+
}
diff --git a/src/main/java/org/apache/maven/shared/project/install/internal/DualDigester.java b/src/main/java/org/apache/maven/shared/project/deploy/internal/DualDigester.java
similarity index 97%
rename from src/main/java/org/apache/maven/shared/project/install/internal/DualDigester.java
rename to src/main/java/org/apache/maven/shared/project/deploy/internal/DualDigester.java
index 000bf65..a2b8c34 100644
--- a/src/main/java/org/apache/maven/shared/project/install/internal/DualDigester.java
+++ b/src/main/java/org/apache/maven/shared/project/deploy/internal/DualDigester.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
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 @@
*
* 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 c37329b..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,53 +26,11 @@
*/
public class ProjectInstallerRequest
{
- // From AbstractInstallMojo
-
- private boolean createChecksum;
-
- private boolean updateReleaseInfo;
-
// 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 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..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
@@ -40,7 +40,6 @@
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 @@
@Requirement
private RepositoryManager repositoryManager;
- private final DualDigester digester = new DualDigester();
-
/**
* {@inheritDoc}
*/
@@ -71,10 +68,9 @@
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();
Artifact artifact = project.getArtifact();
String packaging = project.getPackaging();
@@ -87,11 +83,6 @@
ProjectArtifactMetadata metadata;
- if ( updateReleaseInfo )
- {
- artifact.setRelease( true );
- }
-
Collection<File> metadataFiles = new LinkedHashSet<File>();
if ( isPomArtifact )
@@ -100,9 +91,7 @@
{
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
@@ -120,9 +109,7 @@
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() )
{
@@ -139,12 +126,11 @@
for ( Artifact attached : attachedArtifacts )
{
+ LOGGER.debug( "Installing artifact: ", attached.getId() );
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 )
@@ -159,40 +145,11 @@
}
}
- /**
- * 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 )
{
@@ -205,82 +162,6 @@
}
/**
- * 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/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