[MSHARED-701] - WIP - Remove installation of pom checksum - IT's do not fail
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 c6b8e2e..6a19faa 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
@@ -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.1.1", "3.2.5", "3.3.1", "3.3.9", "3.5.0", "3.5.2", "3.5.3" } )
public class ProjectInstallerTest
{
@@ -76,7 +76,7 @@
result.assertErrorFreeLog();
// Check that the current plugins has been called at least once.
- result.assertLogText( "[INFO] --- maven-project-installer-plugin:1.0.0:project-installer (id-project-installer) @ maven-project-installer-plugin-it ---" );
+ result.assertLogText( "[INFO] --- maven-project-installer-plugin:1.0.0:project-installer (id-project-installer) @ maven-project-installer-project-it ---" );
String mvnVersion = mavenRuntime.getMavenVersion() + "/";
// The "." will be replaced by "/" in the running of the artifact-installer-plugin so I need to do the same
@@ -92,37 +92,82 @@
File baseDirectoy =
new File( localRepo,
- "PROJECT-INSTALLER-GROUPID-" + mvnVersion + "maven-project-installer-plugin-it/1.0.0-A/" );
+ "PROJECT-INSTALLER-GROUPID-" + mvnVersion + "maven-project-installer-project-it/1.0.0-A/" );
- checkForPomFile( baseDirectoy );
+ checkForPomFile( baseDirectoy, "maven-project-installer-project-it", "1.0.0-A" );
- checkForJarFile( baseDirectoy );
+ checkForJarFile( baseDirectoy, "maven-project-installer-project-it", "1.0.0-A" );
- checkForJarClassifierFile( baseDirectoy );
+ checkForJarClassifierFile( baseDirectoy, "maven-project-installer-project-it", "1.0.0-A" );
}
- private void checkForJarClassifierFile( File baseDirectoy )
+ @Test
+ public void buildPomOnlyExample()
+ throws Exception
{
- File jarClassifierFile = new File( baseDirectoy, "maven-project-installer-plugin-it-1.0.0-A-classifier.jar" );
+ File basedir = resources.getBasedir( "pom-only-example" );
+ //@formatter:off
+ MavenExecutionResult result =
+ mavenRuntime
+ .forProject( basedir )
+ .withCliOption( "-DmvnVersion=" + mavenRuntime.getMavenVersion() ) // Might be superfluous
+ .withCliOption( "-B" )
+ .withCliOption( "-V" )
+ // We use verify to prevent running maven-install-plugin.
+ .execute( "clean", "verify" );
+ //@formatter:on
+
+ result.assertErrorFreeLog();
+
+ // Check that the current plugins has been called at least once.
+ result.assertLogText( "[INFO] --- maven-project-installer-plugin:1.0.0:project-installer (id-project-installer) @ maven-project-installer-project-701 ---" );
+
+ String mvnVersion = mavenRuntime.getMavenVersion() + "/";
+ // The "." will be replaced by "/" in the running of the artifact-installer-plugin so I need to do the same
+ // here.
+ // Maybe there is a more elegant way to do that?
+ mvnVersion = mvnVersion.replaceAll( "\\.", "/" );
+
+ String mavenRepoLocal = System.getProperty( "maven.repo.local" );
+ File localRepo = new File( mavenRepoLocal );
+
+ System.out.println( "localRepo='" + localRepo.getAbsolutePath() + "'" );
+ System.out.println( "mvnVersion='" + mvnVersion + "'" );
+
+ File baseDirectoy =
+ new File( localRepo,
+ "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" );
+
+ checkForJarClassifierFile( baseDirectoy, "maven-project-installer-project-701", "2.0.701" );
+
+ }
+
+ private void checkForJarClassifierFile( File baseDirectoy, String baseArtifact, String version )
+ {
+ 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.",
new File( jarClassifierFile.getAbsolutePath() + ".sha1" ).exists() );
}
- private void checkForJarFile( File baseDirectoy )
+ private void checkForJarFile( File baseDirectoy, String baseArtifact, String version )
{
- File jarFile = new File( baseDirectoy, "maven-project-installer-plugin-it-1.0.0-A.jar" );
+ 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() );
}
- private void checkForPomFile( File baseDirectoy )
+ private void checkForPomFile( File baseDirectoy, String baseArtifact, String version )
{
- File pomFile = new File( baseDirectoy, "maven-project-installer-plugin-it-1.0.0-A.pom" );
- assertTrue( "pomFile '" + pomFile.getAbsolutePath() + "'", pomFile.exists() );
+ 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() );
}
diff --git a/src/it/maven-project-installer-plugin/src/test/projects/example/pom.xml b/src/it/maven-project-installer-plugin/src/test/projects/example/pom.xml
index 03d5e5d..2fa5873 100644
--- a/src/it/maven-project-installer-plugin/src/test/projects/example/pom.xml
+++ b/src/it/maven-project-installer-plugin/src/test/projects/example/pom.xml
@@ -30,7 +30,7 @@
</parent>
<groupId>PROJECT-INSTALLER-GROUPID-${mvnVersion}</groupId>
- <artifactId>maven-project-installer-plugin-it</artifactId>
+ <artifactId>maven-project-installer-project-it</artifactId>
<version>1.0.0-A</version>
<build>
diff --git a/src/it/maven-project-installer-plugin/src/test/projects/pom-only-example/pom.xml b/src/it/maven-project-installer-plugin/src/test/projects/pom-only-example/pom.xml
new file mode 100644
index 0000000..31f8c51
--- /dev/null
+++ b/src/it/maven-project-installer-plugin/src/test/projects/pom-only-example/pom.xml
@@ -0,0 +1,70 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+>
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.maven.shared</groupId>
+ <artifactId>maven-shared-components</artifactId>
+ <version>31</version>
+ <relativePath />
+ </parent>
+
+ <groupId>PROJECT-INSTALLER-GROUPID-701-${mvnVersion}</groupId>
+ <artifactId>maven-project-installer-project-701</artifactId>
+ <version>2.0.701</version>
+ <packaging>pom</packaging>
+ <description>Check if installing POM only will fail for current implementation see MSHARED-701</description>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.rat</groupId>
+ <artifactId>apache-rat-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-project-installer-plugin</artifactId>
+ <version>${it-plugin.version}</version>
+ <configuration>
+ <localRepositoryPath>${localRepositoryPath}</localRepositoryPath>
+ <mvnVersion>${mvnVersion}</mvnVersion>
+ </configuration>
+ <executions>
+ <execution>
+ <id>id-project-installer</id>
+ <goals>
+ <goal>project-installer</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
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 8d643c3..f0ee602 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
@@ -100,6 +100,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 );
}
@@ -119,6 +120,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 );
}