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/02/14 20:04:37 UTC
[maven-artifact-transfer] 01/07: [MSHARED-656] Make integration
testing for different Maven versions possible o Added separate integration
test projects to make IT's possible
This is an automated email from the ASF dual-hosted git repository.
khmarbaise pushed a commit to branch MSHARED-656
in repository https://gitbox.apache.org/repos/asf/maven-artifact-transfer.git
commit 15ce72abdc7e3c899ad3209746ef19114b9f8ea0
Author: Karl Heinz Marbaise <kh...@apache.org>
AuthorDate: Thu Dec 21 16:11:54 2017 +0100
[MSHARED-656] Make integration testing for different Maven versions
possible
o Added separate integration test projects to make IT's possible
---
.gitignore | 1 +
pom.xml | 77 ++++++++++++
src/it/maven-artifact-deployer-plugin/pom.xml | 129 ++++++++++++++++++++
.../artifact/deployer/ArtifactDeployerMojo.java | 131 +++++++++++++++++++++
.../artifact/deployer/ArtifactDeployerTest.java | 108 +++++++++++++++++
.../src/test/projects/example/pom.xml | 67 +++++++++++
src/it/maven-artifact-installer-plugin/pom.xml | 129 ++++++++++++++++++++
.../artifact/installer/ArtifactInstallerMojo.java | 128 ++++++++++++++++++++
.../artifact/installer/ArtifactInstallerTest.java | 109 +++++++++++++++++
.../src/test/projects/example/pom.xml | 67 +++++++++++
src/it/settings.xml | 55 +++++++++
.../shared/artifact/install/ArtifactInstaller.java | 10 +-
.../install/internal/DefaultArtifactInstaller.java | 1 -
.../install/internal/Maven31ArtifactInstaller.java | 1 -
.../shared/project/deploy/ProjectDeployer.java | 3 +
.../deploy/internal/DefaultProjectDeployer.java | 3 +
.../shared/project/install/ProjectInstaller.java | 2 +
.../{install-project.apt => deploy-project.apt} | 21 ++--
src/site/apt/install-project.apt | 9 +-
.../internal/DefaultArtifactDeployerTest.java | 12 +-
.../internal/DefaultArtifactInstallerTest.java | 3 +-
21 files changed, 1039 insertions(+), 27 deletions(-)
diff --git a/.gitignore b/.gitignore
index d0d7222..3578f45 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,5 +12,6 @@ out/
.DS_Store
/bootstrap
/dependencies.xml
+/dependency-reduced-pom.xml
.java-version
dependency-reduced-pom.xml
diff --git a/pom.xml b/pom.xml
index 01719f6..961887f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -56,6 +56,9 @@
</site>
</distributionManagement>
+ <properties>
+ <javaVersion>7</javaVersion>
+ </properties>
<build>
<plugins>
<plugin>
@@ -106,6 +109,7 @@
<plugin>
<groupId>org.apache.rat</groupId>
<artifactId>apache-rat-plugin</artifactId>
+ <version>0.12</version>
<configuration>
<excludes combine.children="append">
<exclude>dependency-reduced-pom.xml</exclude>
@@ -153,6 +157,7 @@
</execution>
</executions>
</plugin>
+
</plugins>
</build>
@@ -243,6 +248,7 @@
<version>4.11</version>
<scope>test</scope>
</dependency>
+
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
@@ -264,4 +270,75 @@
</pluginRepository>
</pluginRepositories>
+ <profiles>
+ <profile>
+ <id>run-its</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-invoker-plugin</artifactId>
+ <version>3.0.1</version>
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.groovy</groupId>
+ <artifactId>groovy</artifactId>
+ <version>2.4.10</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.gmaven.runtime</groupId>
+ <artifactId>gmaven-runtime-2.0</artifactId>
+ <version>1.5</version>
+ </dependency>
+ </dependencies>
+ <configuration>
+ <addTestClassPath>true</addTestClassPath>
+ <debug>false</debug>
+ <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
+ <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
+ <projectsDirectory>src/it</projectsDirectory>
+ <showVersion>false</showVersion>
+ <pomIncludes>
+ <pomInclude>*/pom.xml</pomInclude>
+ </pomIncludes>
+ <preBuildHookScript>setup</preBuildHookScript>
+ <postBuildHookScript>verify</postBuildHookScript>
+ <settingsFile>src/it/settings.xml</settingsFile>
+ <!-- Currently working with more than one thread does not work, cause
+ it is not guaranteed that the setup-config project is build at first. see
+ also http://jira.codehaus.org/browse/MINVOKER-147 -->
+ <parallelThreads>1</parallelThreads>
+ <filterProperties>
+ <repository.proxy.url>${repository.proxy.url}</repository.proxy.url>
+ <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
+ </filterProperties>
+ <extraArtifacts>
+ <extraArtifact>org.apache.maven:apache-maven:3.0.5:tar.gz:bin</extraArtifact>
+ <extraArtifact>org.apache.maven:apache-maven:3.1.1:tar.gz:bin</extraArtifact>
+ <extraArtifact>org.apache.maven:apache-maven:3.2.5:tar.gz:bin</extraArtifact>
+ <extraArtifact>org.apache.maven:apache-maven:3.3.1:tar.gz:bin</extraArtifact>
+ <extraArtifact>org.apache.maven:apache-maven:3.3.9:tar.gz:bin</extraArtifact>
+ <extraArtifact>org.apache.maven:apache-maven:3.5.0:tar.gz:bin</extraArtifact>
+ </extraArtifacts>
+ </configuration>
+ <executions>
+ <execution>
+ <id>pre-integration-tests</id>
+ <goals>
+ <goal>install</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>integration-tests</id>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+
+ </build>
+ </profile>
+ </profiles>
</project>
diff --git a/src/it/maven-artifact-deployer-plugin/pom.xml b/src/it/maven-artifact-deployer-plugin/pom.xml
new file mode 100644
index 0000000..64ce850
--- /dev/null
+++ b/src/it/maven-artifact-deployer-plugin/pom.xml
@@ -0,0 +1,129 @@
+<?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.plugins</groupId>
+ <artifactId>maven-plugins</artifactId>
+ <version>30</version>
+ <relativePath />
+ </parent>
+
+ <artifactId>maven-artifact-deployer-plugin</artifactId>
+ <version>1.0.0</version>
+ <packaging>maven-plugin</packaging>
+
+ <name>Apache Maven Artifact Deployer Plugin</name>
+ <description>The plugin is only intended as a real testing environment for maven-artifact-deployer component.</description>
+ <prerequisites>
+ <maven>${mavenVersion}</maven>
+ </prerequisites>
+
+ <properties>
+ <mavenVersion>3.0</mavenVersion>
+ <javaVersion>8</javaVersion>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>${mavenVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-artifact</artifactId>
+ <version>${mavenVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.shared</groupId>
+ <artifactId>maven-artifact-transfer</artifactId>
+ <version>@project.version@</version>
+<!-- <version>0.10.0-SNAPSHOT</version> -->
+ </dependency>
+
+ <!-- dependencies to annotations -->
+ <dependency>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-annotations</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>io.takari.maven.plugins</groupId>
+ <artifactId>takari-plugin-integration-testing</artifactId>
+ <version>2.9.1</version>
+ <type>pom</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>io.takari.maven.plugins</groupId>
+ <artifactId>takari-plugin-testing</artifactId>
+ <version>2.9.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.rat</groupId>
+ <artifactId>apache-rat-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemProperties>
+ <maven.local.repo>${maven.local.repo}</maven.local.repo>
+ <localRepositoryPath>${localRepositoryPath}</localRepositoryPath>
+ <mvnVersion>${mvnVersion}</mvnVersion>
+ </systemProperties>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>io.takari.maven.plugins</groupId>
+ <artifactId>takari-lifecycle-plugin</artifactId>
+ <version>1.13.1</version>
+ <executions>
+ <execution>
+ <?m2e ignore ?>
+ <id>testProperties</id>
+ <phase>process-test-resources</phase>
+ <goals>
+ <goal>testProperties</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+
+ </build>
+</project>
diff --git a/src/it/maven-artifact-deployer-plugin/src/main/java/org/apache/maven/plugin/artifact/deployer/ArtifactDeployerMojo.java b/src/it/maven-artifact-deployer-plugin/src/main/java/org/apache/maven/plugin/artifact/deployer/ArtifactDeployerMojo.java
new file mode 100644
index 0000000..e97a7bf
--- /dev/null
+++ b/src/it/maven-artifact-deployer-plugin/src/main/java/org/apache/maven/plugin/artifact/deployer/ArtifactDeployerMojo.java
@@ -0,0 +1,131 @@
+package org.apache.maven.plugin.artifact.deployer;
+
+/*
+ * 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.FileOutputStream;
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.DefaultArtifact;
+import org.apache.maven.artifact.handler.DefaultArtifactHandler;
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.project.ProjectBuildingRequest;
+import org.apache.maven.shared.artifact.deploy.ArtifactDeployer;
+import org.apache.maven.shared.artifact.deploy.ArtifactDeployerException;
+import org.apache.maven.shared.repository.RepositoryManager;
+
+/**
+ * This mojo is implemented to test the ArtifactDeployer part of the maven-artifact-transfer shared component.
+ */
+@Mojo( name = "artifact-deployer", defaultPhase = LifecyclePhase.VERIFY, threadSafe = true )
+public class ArtifactDeployerMojo
+ extends AbstractMojo
+{
+
+ /**
+ * Parameter to have different locations for each Maven version we are testing with.
+ */
+ @Parameter
+ private String mvnVersion;
+
+ @Component
+ protected RepositoryManager repositoryManager;
+
+ @Parameter( defaultValue = "${session}", required = true, readonly = true )
+ protected MavenSession session;
+
+ @Component
+ private ArtifactDeployer deployer;
+
+ public void execute()
+ throws MojoExecutionException, MojoFailureException
+ {
+ getLog().info( "Hello from artifact-deployer plugin" );
+ deployerProject( session.getProjectBuildingRequest() );
+ getLog().info( "Bye bye from artifact-deployer plugin" );
+ }
+
+ private void createFileContent( File outputFile )
+ throws IOException
+ {
+ Path file = outputFile.toPath();
+ List<String> asList = Arrays.asList( "Line 1", "Line 2" );
+ Files.write( file, asList, Charset.forName( "UTF-8" ) );
+ }
+
+ private void deployerProject( ProjectBuildingRequest pbr )
+ throws MojoFailureException, MojoExecutionException
+ {
+ try
+ {
+ DefaultArtifactHandler artifactHandler = new DefaultArtifactHandler();
+ artifactHandler.setExtension( "EXTENSION" );
+
+ File artifactsDirectory =
+ new File( session.getCurrentProject().getBuild().getDirectory(), "tests/artifacts" );
+ getLog().info( "Directory: '" + artifactsDirectory.getAbsolutePath() + "'" );
+ artifactsDirectory.mkdirs();
+
+ File tmpFile = File.createTempFile( "test-deploy", ".jar", artifactsDirectory );
+ createFileContent( tmpFile );
+
+ DefaultArtifact artifact = new DefaultArtifact( "DEPLOYER-GROUPID-" + mvnVersion, "ARTIFACTID", "VERSION",
+ "compile", "jar", null, artifactHandler );
+ artifact.setFile( tmpFile );
+ artifact.setRepository( session.getProjectBuildingRequest().getLocalRepository() );
+
+ DefaultArtifact artifactWithClassifier =
+ new DefaultArtifact( "DEPLOYER-GROUPID-" + mvnVersion, "ARTIFACTID", "VERSION", "compile", "jar",
+ "CLASSIFIER", artifactHandler );
+ File tmpFileClassifier = File.createTempFile( "test-deploy-classifier", ".jar", artifactsDirectory );
+ createFileContent( tmpFileClassifier );
+ artifactWithClassifier.setFile( tmpFileClassifier );
+ artifactWithClassifier.setRepository( session.getProjectBuildingRequest().getLocalRepository() );
+
+ Collection<Artifact> mavenArtifacts = Arrays.<Artifact>asList( artifact, artifactWithClassifier );
+
+ deployer.deploy( session.getProjectBuildingRequest(), mavenArtifacts );
+ }
+ catch ( ArtifactDeployerException e )
+ {
+ throw new MojoExecutionException( "ArtifactDeployerException", e );
+ }
+ catch ( IOException e )
+ {
+ throw new MojoExecutionException( "IOException", e );
+ }
+ }
+
+}
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
new file mode 100644
index 0000000..e5a7fa5
--- /dev/null
+++ b/src/it/maven-artifact-deployer-plugin/src/test/java/org/apache/maven/plugin/artifact/deployer/ArtifactDeployerTest.java
@@ -0,0 +1,108 @@
+package org.apache.maven.plugin.artifact.deployer;
+
+/*
+ * 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 static org.junit.Assert.assertTrue;
+
+import java.io.File;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import io.takari.maven.testing.TestResources;
+import io.takari.maven.testing.executor.MavenExecutionResult;
+import io.takari.maven.testing.executor.MavenRuntime;
+import io.takari.maven.testing.executor.MavenRuntime.MavenRuntimeBuilder;
+import io.takari.maven.testing.executor.MavenVersions;
+import io.takari.maven.testing.executor.junit.MavenJUnitTestRunner;
+
+/**
+ * This will check if the ArtifactInstaller works for all Maven versions 3.0.5, 3.1.1, 3.2.5, 3.3.1, 3.3.9, 3.5.0. This
+ * is done by using the test plugin <code>maven-artifact-deployer-plugin</code> which uses the ArtifactInstaller as component.
+ * By using this way we get a real runtime environment which supports all Maven versions.
+ *
+ * @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" } )
+public class ArtifactDeployerTest
+{
+
+ @Rule
+ public final TestResources resources = new TestResources();
+
+ public final MavenRuntime mavenRuntime;
+
+ public ArtifactDeployerTest( MavenRuntimeBuilder builder )
+ throws Exception
+ {
+ this.mavenRuntime = builder.build();
+ }
+
+ @Test
+ public void buildExample()
+ throws Exception
+ {
+ File basedir = resources.getBasedir( "example" );
+ //@formatter:off
+ MavenExecutionResult result =
+ mavenRuntime
+ .forProject( basedir )
+ .withCliOption( "-DmvnVersion=" + mavenRuntime.getMavenVersion() ) // Might be superfluous
+ .withCliOption( "-B" )
+ .withCliOption( "-V" )
+ .execute( "clean", "verify" );
+ //@formatter:on
+
+ result.assertErrorFreeLog();
+ // Check that the current plugins has been called at least once.
+ result.assertLogText( "[INFO] --- maven-artifact-deployer-plugin:1.0.0:artifact-deployer (id-artifact-deployer) @ maven-artifact-deployer-plugin-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 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 + "'" );
+
+ // The real checking of what should had happen..
+
+ assertTrue( new File( localRepo,
+ "DEPLOYER-GROUPID-" + mvnVersion + "/ARTIFACTID/VERSION/ARTIFACTID-VERSION.EXTENSION" ).exists() );
+ assertTrue( new File( localRepo,
+ "DEPLOYER-GROUPID-" + mvnVersion + "/ARTIFACTID/VERSION/ARTIFACTID-VERSION.EXTENSION.md5" ).exists() );
+ assertTrue( new File( localRepo,
+ "DEPLOYER-GROUPID-" + mvnVersion + "/ARTIFACTID/VERSION/ARTIFACTID-VERSION.EXTENSION.sha1" ).exists() );
+
+ assertTrue( new File( localRepo, "DEPLOYER-GROUPID-" + mvnVersion
+ + "/ARTIFACTID/VERSION/ARTIFACTID-VERSION-CLASSIFIER.EXTENSION" ).exists() );
+ assertTrue( new File( localRepo, "DEPLOYER-GROUPID-" + mvnVersion
+ + "/ARTIFACTID/VERSION/ARTIFACTID-VERSION-CLASSIFIER.EXTENSION.md5" ).exists() );
+ assertTrue( new File( localRepo, "DEPLOYER-GROUPID-" + mvnVersion
+ + "/ARTIFACTID/VERSION/ARTIFACTID-VERSION-CLASSIFIER.EXTENSION.sha1" ).exists() );
+ assertTrue( new File( localRepo, "DEPLOYER-GROUPID-" + mvnVersion + "/ARTIFACTID/maven-metadata-local.xml" ).exists() ); // ??
+
+ }
+}
\ No newline at end of file
diff --git a/src/it/maven-artifact-deployer-plugin/src/test/projects/example/pom.xml b/src/it/maven-artifact-deployer-plugin/src/test/projects/example/pom.xml
new file mode 100644
index 0000000..f4f14c9
--- /dev/null
+++ b/src/it/maven-artifact-deployer-plugin/src/test/projects/example/pom.xml
@@ -0,0 +1,67 @@
+<?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>30</version>
+ <relativePath />
+ </parent>
+
+ <artifactId>maven-artifact-deployer-plugin-it</artifactId>
+ <version>1.0.0-A</version>
+
+ <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-artifact-deployer-plugin</artifactId>
+ <version>${it-plugin.version}</version>
+ <configuration>
+ <localRepositoryPath>${localRepositoryPath}</localRepositoryPath>
+ <mvnVersion>${mvnVersion}</mvnVersion>
+ </configuration>
+ <executions>
+ <execution>
+ <id>id-artifact-deployer</id>
+ <goals>
+ <goal>artifact-deployer</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/src/it/maven-artifact-installer-plugin/pom.xml b/src/it/maven-artifact-installer-plugin/pom.xml
new file mode 100644
index 0000000..dd3b6fc
--- /dev/null
+++ b/src/it/maven-artifact-installer-plugin/pom.xml
@@ -0,0 +1,129 @@
+<?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.plugins</groupId>
+ <artifactId>maven-plugins</artifactId>
+ <version>30</version>
+ <relativePath />
+ </parent>
+
+ <artifactId>maven-artifact-installer-plugin</artifactId>
+ <version>1.0.0</version>
+ <packaging>maven-plugin</packaging>
+
+ <name>Apache Maven Artifact Installer Plugin</name>
+ <description>The plugin is only intended as a real testing environment for maven-artifact-transfer component.</description>
+ <prerequisites>
+ <maven>${mavenVersion}</maven>
+ </prerequisites>
+
+ <properties>
+ <mavenVersion>3.0</mavenVersion>
+ <javaVersion>8</javaVersion>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>${mavenVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-artifact</artifactId>
+ <version>${mavenVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.shared</groupId>
+ <artifactId>maven-artifact-transfer</artifactId>
+ <version>@project.version@</version>
+<!-- <version>0.10.0-SNAPSHOT</version> -->
+ </dependency>
+
+ <!-- dependencies to annotations -->
+ <dependency>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-annotations</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>io.takari.maven.plugins</groupId>
+ <artifactId>takari-plugin-integration-testing</artifactId>
+ <version>2.9.1</version>
+ <type>pom</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>io.takari.maven.plugins</groupId>
+ <artifactId>takari-plugin-testing</artifactId>
+ <version>2.9.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.rat</groupId>
+ <artifactId>apache-rat-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemProperties>
+ <maven.local.repo>${maven.local.repo}</maven.local.repo>
+ <localRepositoryPath>${localRepositoryPath}</localRepositoryPath>
+ <mvnVersion>${mvnVersion}</mvnVersion>
+ </systemProperties>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>io.takari.maven.plugins</groupId>
+ <artifactId>takari-lifecycle-plugin</artifactId>
+ <version>1.13.1</version>
+ <executions>
+ <execution>
+ <?m2e ignore ?>
+ <id>testProperties</id>
+ <phase>process-test-resources</phase>
+ <goals>
+ <goal>testProperties</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+
+ </build>
+</project>
diff --git a/src/it/maven-artifact-installer-plugin/src/main/java/org/apache/maven/plugin/artifact/installer/ArtifactInstallerMojo.java b/src/it/maven-artifact-installer-plugin/src/main/java/org/apache/maven/plugin/artifact/installer/ArtifactInstallerMojo.java
new file mode 100644
index 0000000..d95ccfb
--- /dev/null
+++ b/src/it/maven-artifact-installer-plugin/src/main/java/org/apache/maven/plugin/artifact/installer/ArtifactInstallerMojo.java
@@ -0,0 +1,128 @@
+package org.apache.maven.plugin.artifact.installer;
+
+/*
+ * 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.IOException;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.DefaultArtifact;
+import org.apache.maven.artifact.handler.DefaultArtifactHandler;
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.project.ProjectBuildingRequest;
+import org.apache.maven.shared.artifact.install.ArtifactInstaller;
+import org.apache.maven.shared.artifact.install.ArtifactInstallerException;
+import org.apache.maven.shared.repository.RepositoryManager;
+
+/**
+ * This mojo is implemented to test the ArtifactInstaller part of the maven-artifact-transfer shared component.
+ */
+@Mojo( name = "artifact-installer", defaultPhase = LifecyclePhase.VERIFY, threadSafe = true )
+public class ArtifactInstallerMojo
+ extends AbstractMojo
+{
+
+ /**
+ * Parameter to have different locations for each Maven version we are testing with.
+ */
+ @Parameter
+ private String mvnVersion;
+
+ @Component
+ protected RepositoryManager repositoryManager;
+
+ @Parameter( defaultValue = "${session}", required = true, readonly = true )
+ protected MavenSession session;
+
+ @Component
+ private ArtifactInstaller installer;
+
+ public void execute()
+ throws MojoExecutionException, MojoFailureException
+ {
+ getLog().info( "Hello from artifact-installer plugin" );
+ installProject( session.getProjectBuildingRequest() );
+ getLog().info( "Bye bye from artifact-installer plugin" );
+ }
+
+ private void createFileContent( File outputFile )
+ throws IOException
+ {
+ Path file = outputFile.toPath();
+ List<String> asList = Arrays.asList( "Line 1", "Line 2" );
+ Files.write( file, asList, Charset.forName( "UTF-8" ) );
+ }
+
+ private void installProject( ProjectBuildingRequest pbr )
+ throws MojoFailureException, MojoExecutionException
+ {
+ try
+ {
+ DefaultArtifactHandler artifactHandler = new DefaultArtifactHandler();
+ artifactHandler.setExtension( "EXTENSION" );
+
+ File artifactsDirectory =
+ new File( session.getCurrentProject().getBuild().getDirectory(), "tests/artifacts" );
+ getLog().info( "Directory: '" + artifactsDirectory.getAbsolutePath() + "'" );
+ artifactsDirectory.mkdirs();
+
+ File tmpFile = File.createTempFile( "test-install", ".jar", artifactsDirectory );
+ createFileContent( tmpFile );
+
+ DefaultArtifact artifact = new DefaultArtifact( "GROUPID-" + mvnVersion, "ARTIFACTID", "VERSION", "compile",
+ "jar", null, artifactHandler );
+ artifact.setFile( tmpFile );
+ DefaultArtifact artifactWithClassifier =
+ new DefaultArtifact( "GROUPID-" + mvnVersion, "ARTIFACTID", "VERSION", "compile", "jar", "CLASSIFIER",
+ artifactHandler );
+
+ File tmpFileClassifier = File.createTempFile( "test-install-classifier", ".jar", artifactsDirectory );
+ createFileContent( tmpFileClassifier );
+ artifactWithClassifier.setFile( tmpFileClassifier );
+
+ Collection<Artifact> mavenArtifacts = Arrays.<Artifact>asList( artifact, artifactWithClassifier );
+
+ installer.install( session.getProjectBuildingRequest(), mavenArtifacts );
+ }
+ catch ( ArtifactInstallerException e )
+ {
+ throw new MojoExecutionException( "ArtifactInstallerException", e );
+ }
+ catch ( IOException e )
+ {
+ throw new MojoExecutionException( "IOException", e );
+ }
+
+ }
+
+}
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
new file mode 100644
index 0000000..08ad0fd
--- /dev/null
+++ b/src/it/maven-artifact-installer-plugin/src/test/java/org/apache/maven/plugin/artifact/installer/ArtifactInstallerTest.java
@@ -0,0 +1,109 @@
+package org.apache.maven.plugin.artifact.installer;
+
+/*
+ * 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 static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import io.takari.maven.testing.TestResources;
+import io.takari.maven.testing.executor.MavenExecutionResult;
+import io.takari.maven.testing.executor.MavenRuntime;
+import io.takari.maven.testing.executor.MavenRuntime.MavenRuntimeBuilder;
+import io.takari.maven.testing.executor.MavenVersions;
+import io.takari.maven.testing.executor.junit.MavenJUnitTestRunner;
+
+/**
+ * This will check if the ArtifactInstaller works for all Maven versions 3.0.5, 3.1.1, 3.2.5, 3.3.1, 3.3.9, 3.5.0. This
+ * is done by using the test plugin <code>maven-artifact-installer-plugin</code> which uses the ArtifactInstaller as component.
+ * By using this way we get a real runtime environment which supports all Maven versions.
+ *
+ * @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" } )
+public class ArtifactInstallerTest
+{
+
+ @Rule
+ public final TestResources resources = new TestResources();
+
+ public final MavenRuntime mavenRuntime;
+
+ public ArtifactInstallerTest( MavenRuntimeBuilder builder )
+ throws Exception
+ {
+ this.mavenRuntime = builder.build();
+ }
+
+ @Test
+ public void buildExample()
+ throws Exception
+ {
+ File basedir = resources.getBasedir( "example" );
+ //@formatter:off
+ MavenExecutionResult result =
+ mavenRuntime
+ .forProject( basedir )
+ .withCliOption( "-DmvnVersion=" + mavenRuntime.getMavenVersion() ) // Might be superfluous
+ .withCliOption( "-B" )
+ .withCliOption( "-V" )
+ .execute( "clean", "verify" );
+ //@formatter:on
+
+ result.assertErrorFreeLog();
+ // Check that the current plugins has been called at least once.
+ result.assertLogText( "[INFO] --- maven-artifact-installer-plugin:1.0.0:artifact-installer (id-artifact-installer) @ maven-artifact-installer-plugin-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
+ // 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 + "'" );
+
+ // The real checking of what should had happen..
+ assertTrue( new File( localRepo,
+ "GROUPID-" + mvnVersion + "/ARTIFACTID/VERSION/ARTIFACTID-VERSION.EXTENSION" ).exists() );
+ assertFalse( new File( localRepo, "GROUPID-" + mvnVersion
+ + "/ARTIFACTID/VERSION/ARTIFACTID-VERSION.EXTENSION.md5" ).exists() );
+ assertFalse( new File( localRepo, "GROUPID-" + mvnVersion
+ + "/ARTIFACTID/VERSION/ARTIFACTID-VERSION.EXTENSION.sha1" ).exists() );
+
+ assertTrue( new File( localRepo, "GROUPID-" + mvnVersion
+ + "/ARTIFACTID/VERSION/ARTIFACTID-VERSION-CLASSIFIER.EXTENSION" ).exists() );
+ assertFalse( new File( localRepo, "GROUPID-" + mvnVersion
+ + "/ARTIFACTID/VERSION/ARTIFACTID-VERSION-CLASSIFIER.EXTENSION.md5" ).exists() );
+ assertFalse( new File( localRepo, "GROUPID-" + mvnVersion
+ + "/ARTIFACTID/VERSION/ARTIFACTID-VERSION-CLASSIFIER.EXTENSION.sha1" ).exists() );
+ assertTrue( new File( localRepo, "GROUPID-" + mvnVersion + "/ARTIFACTID/maven-metadata-local.xml" ).exists() ); // ??
+
+ }
+}
\ No newline at end of file
diff --git a/src/it/maven-artifact-installer-plugin/src/test/projects/example/pom.xml b/src/it/maven-artifact-installer-plugin/src/test/projects/example/pom.xml
new file mode 100644
index 0000000..3332df5
--- /dev/null
+++ b/src/it/maven-artifact-installer-plugin/src/test/projects/example/pom.xml
@@ -0,0 +1,67 @@
+<?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>30</version>
+ <relativePath />
+ </parent>
+
+ <artifactId>maven-artifact-installer-plugin-it</artifactId>
+ <version>1.0.0-A</version>
+
+ <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-artifact-installer-plugin</artifactId>
+ <version>${it-plugin.version}</version>
+ <configuration>
+ <localRepositoryPath>${localRepositoryPath}</localRepositoryPath>
+ <mvnVersion>${mvnVersion}</mvnVersion>
+ </configuration>
+ <executions>
+ <execution>
+ <id>id-artifact-installer</id>
+ <goals>
+ <goal>artifact-installer</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/src/it/settings.xml b/src/it/settings.xml
new file mode 100644
index 0000000..c8f77f0
--- /dev/null
+++ b/src/it/settings.xml
@@ -0,0 +1,55 @@
+<?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.
+-->
+
+<settings>
+ <profiles>
+ <profile>
+ <id>it-repo</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <repositories>
+ <repository>
+ <id>local.central</id>
+ <url>@localRepositoryUrl@</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+ <pluginRepositories>
+ <pluginRepository>
+ <id>local.central</id>
+ <url>@localRepositoryUrl@</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </pluginRepository>
+ </pluginRepositories>
+ </profile>
+ </profiles>
+</settings>
diff --git a/src/main/java/org/apache/maven/shared/artifact/install/ArtifactInstaller.java b/src/main/java/org/apache/maven/shared/artifact/install/ArtifactInstaller.java
index f9cadf2..92c2973 100644
--- a/src/main/java/org/apache/maven/shared/artifact/install/ArtifactInstaller.java
+++ b/src/main/java/org/apache/maven/shared/artifact/install/ArtifactInstaller.java
@@ -33,14 +33,14 @@ public interface ArtifactInstaller
/**
* @param request {@link ProjectBuildingRequest}
- * @param mavenArtifacts {@link Artifact}
+ * @param mavenArtifacts {@link Artifact} (no null or empty collection allowed.)
* @throws ArtifactInstallerException in case of an error.
- * @throws IllegalArgumentException in case of parameter <code>request</code> is <code>null</code> or parameter
- * <code>mavenArtifacts</code> is <code>null</code> or <code>mavenArtifacts.isEmpty()</code> is
- * <code>true</code>.
+ * @throws IllegalArgumentException in case <code>request</code> is <code>null</code>, <code>mavenArtifacts</code>
+ * is <code>null</code> or <code>mavenArtifacts</code> is empty (<code>mavenArtifacts.isEmpty()</code>
+ * == <code>true</code>).
*/
void install( ProjectBuildingRequest request, Collection<Artifact> mavenArtifacts )
- throws ArtifactInstallerException;
+ throws ArtifactInstallerException, IllegalArgumentException;
/**
* @param request {@link ProjectBuildingRequest}.
diff --git a/src/main/java/org/apache/maven/shared/artifact/install/internal/DefaultArtifactInstaller.java b/src/main/java/org/apache/maven/shared/artifact/install/internal/DefaultArtifactInstaller.java
index 5d39501..4f4dbea 100644
--- a/src/main/java/org/apache/maven/shared/artifact/install/internal/DefaultArtifactInstaller.java
+++ b/src/main/java/org/apache/maven/shared/artifact/install/internal/DefaultArtifactInstaller.java
@@ -49,7 +49,6 @@ public class DefaultArtifactInstaller
throws ArtifactInstallerException, IllegalArgumentException
{
validateParameters( request, mavenArtifacts );
-
try
{
String hint = isMaven31() ? "maven31" : "maven3";
diff --git a/src/main/java/org/apache/maven/shared/artifact/install/internal/Maven31ArtifactInstaller.java b/src/main/java/org/apache/maven/shared/artifact/install/internal/Maven31ArtifactInstaller.java
index 2d7dbc0..5eaced1 100644
--- a/src/main/java/org/apache/maven/shared/artifact/install/internal/Maven31ArtifactInstaller.java
+++ b/src/main/java/org/apache/maven/shared/artifact/install/internal/Maven31ArtifactInstaller.java
@@ -46,7 +46,6 @@ import org.eclipse.aether.util.artifact.SubArtifact;
public class Maven31ArtifactInstaller
implements ArtifactInstaller
{
-
@Requirement
private RepositorySystem repositorySystem;
diff --git a/src/main/java/org/apache/maven/shared/project/deploy/ProjectDeployer.java b/src/main/java/org/apache/maven/shared/project/deploy/ProjectDeployer.java
index 2c4519b..ce99e78 100644
--- a/src/main/java/org/apache/maven/shared/project/deploy/ProjectDeployer.java
+++ b/src/main/java/org/apache/maven/shared/project/deploy/ProjectDeployer.java
@@ -57,6 +57,9 @@ public interface ProjectDeployer
* @throws NoFileAssignedException In case of missing file which has not been assigned to project.
* @throws IllegalArgumentException in case of artifact is not correctly assigned.
*/
+ // TODO: Think about null check for projectBuildingRequest?
+ // TODO: Think about null check for projectDeployerRequest?
+ // TODO: Think about null check for artifactRepository?
void deploy( ProjectBuildingRequest buildingRequest, ProjectDeployerRequest request,
ArtifactRepository artifactRepository )
throws NoFileAssignedException, IllegalArgumentException;
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 e1a14af..c15ef4f 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
@@ -85,6 +85,9 @@ public 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 ( request.isUpdateReleaseInfo() )
{
artifact.setRelease( true );
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 0ddc46c..247fd7d 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
@@ -73,6 +73,8 @@ public interface ProjectInstaller
* @throws IllegalArgumentException in case of parameter <code>projectBuildingRequest</code> is <code>null</code> or
* parameter <code>projectInstallerRequest</code> is <code>null</code>.
*/
+ // TODO: Think about null check for projectBuildingRequest?
+ // TODO: Think about null check for projectInstallerRequest?
void install( ProjectBuildingRequest projectBuildingRequest, ProjectInstallerRequest projectInstallerRequest )
throws IOException, ArtifactInstallerException, NoFileAssignedException, IllegalArgumentException;
diff --git a/src/site/apt/install-project.apt b/src/site/apt/deploy-project.apt
similarity index 70%
copy from src/site/apt/install-project.apt
copy to src/site/apt/deploy-project.apt
index eb07a08..eb3e81d 100644
--- a/src/site/apt/install-project.apt
+++ b/src/site/apt/deploy-project.apt
@@ -1,9 +1,9 @@
-----
- Install Project
+ Deploy Project
-----
Karl Heinz Marbaise
-----
- 2017-05-07
+ 2017-08-20
-----
~~ Licensed to the Apache Software Foundation (ASF) under one
@@ -26,10 +26,10 @@
~~ NOTE: For help with the syntax of this file, see:
~~ http://maven.apache.org/doxia/references/apt-format.html
-Install a Project
+Deploy a Project
- If you are developing a maven plugin you need often to install artifacts
- into the local repository which is a little bit cumbersome. This can be easily
+ If you are developing a maven plugin you need often to deploy a whole project
+ into a repository which is a little bit cumbersome. This can be easily
done via the following code parts.
+---
@@ -39,15 +39,16 @@ Install a Project
private MavenProject project;
@Component
- private ProjectInstaller installer;
+ private ProjectDeployer deployer;
...
public void execute() {
- ProjectInstallerRequest pir =
- new ProjectInstallerRequest()
- .setProject( project ).setUpdateReleaseInfo( updateReleaseInfo );
+ ProjectDeployerRequest pir =
+ new ProjectDeployerRequest()
+ //TODO: Think about setUpdateReleaseInfo()..
+ .setProject( project ).setUpdateReleaseInfo( true );
- installer.install( session.getProjectBuildingRequest(), pir );
+ deployer.deploy( session.getProjectBuildingRequest(), pir );
...
}
diff --git a/src/site/apt/install-project.apt b/src/site/apt/install-project.apt
index eb07a08..3d02631 100644
--- a/src/site/apt/install-project.apt
+++ b/src/site/apt/install-project.apt
@@ -28,9 +28,9 @@
Install a Project
- If you are developing a maven plugin you need often to install artifacts
- into the local repository which is a little bit cumbersome. This can be easily
- done via the following code parts.
+ If you are developing a maven plugin or other components related to Maven you need
+ often to install artifacts into the local repository which is a little bit cumbersome.
+ This can be easily done via the following code parts.
+---
@Parameter ( defaultValue = "${session}", required = true, readonly = true)
@@ -45,8 +45,9 @@ Install a Project
ProjectInstallerRequest pir =
new ProjectInstallerRequest()
+ //TODO: THink about setUpdateReleaseInfo()..
.setProject( project ).setUpdateReleaseInfo( updateReleaseInfo );
-
+
installer.install( session.getProjectBuildingRequest(), pir );
...
}
diff --git a/src/test/java/org/apache/maven/shared/artifact/deploy/internal/DefaultArtifactDeployerTest.java b/src/test/java/org/apache/maven/shared/artifact/deploy/internal/DefaultArtifactDeployerTest.java
index cfd9587..5e17f60 100644
--- a/src/test/java/org/apache/maven/shared/artifact/deploy/internal/DefaultArtifactDeployerTest.java
+++ b/src/test/java/org/apache/maven/shared/artifact/deploy/internal/DefaultArtifactDeployerTest.java
@@ -64,9 +64,10 @@ public class DefaultArtifactDeployerTest
public void deployShouldReturnIllegalArgumentExceptionForSecondParameterWithNull()
throws ArtifactDeployerException
{
+ ProjectBuildingRequest pbr = mock( ProjectBuildingRequest.class );
+
thrown.expect( IllegalArgumentException.class );
thrown.expectMessage( "The parameter mavenArtifacts is not allowed to be null." );
- ProjectBuildingRequest pbr = mock( ProjectBuildingRequest.class );
dap.deploy( pbr, null );
}
@@ -74,9 +75,10 @@ public class DefaultArtifactDeployerTest
public void deployShouldReturnIllegalArgumentExceptionForSecondParameterWithEmpty()
throws ArtifactDeployerException
{
+ ProjectBuildingRequest pbr = mock( ProjectBuildingRequest.class );
+
thrown.expect( IllegalArgumentException.class );
thrown.expectMessage( "The collection mavenArtifacts is not allowed to be empty." );
- ProjectBuildingRequest pbr = mock( ProjectBuildingRequest.class );
dap.deploy( pbr, Collections.<Artifact>emptyList() );
}
@@ -94,9 +96,10 @@ public class DefaultArtifactDeployerTest
public void deploy3ParametersShouldReturnIllegalArgumentExceptionForSecondParameterWithNull()
throws ArtifactDeployerException
{
+ ProjectBuildingRequest pbr = mock( ProjectBuildingRequest.class );
+
thrown.expect( IllegalArgumentException.class );
thrown.expectMessage( "The parameter mavenArtifacts is not allowed to be null." );
- ProjectBuildingRequest pbr = mock( ProjectBuildingRequest.class );
dap.deploy( pbr, null, null );
}
@@ -104,9 +107,10 @@ public class DefaultArtifactDeployerTest
public void deploy3ParametersShouldReturnIllegalArgumentExceptionForSecondParameterWithEmpty()
throws ArtifactDeployerException
{
+ ProjectBuildingRequest pbr = mock( ProjectBuildingRequest.class );
+
thrown.expect( IllegalArgumentException.class );
thrown.expectMessage( "The collection mavenArtifacts is not allowed to be empty." );
- ProjectBuildingRequest pbr = mock( ProjectBuildingRequest.class );
dap.deploy( pbr, null, Collections.<Artifact>emptyList() );
}
diff --git a/src/test/java/org/apache/maven/shared/artifact/install/internal/DefaultArtifactInstallerTest.java b/src/test/java/org/apache/maven/shared/artifact/install/internal/DefaultArtifactInstallerTest.java
index 144f33f..d26ed01 100644
--- a/src/test/java/org/apache/maven/shared/artifact/install/internal/DefaultArtifactInstallerTest.java
+++ b/src/test/java/org/apache/maven/shared/artifact/install/internal/DefaultArtifactInstallerTest.java
@@ -45,8 +45,7 @@ public class DefaultArtifactInstallerTest
public ExpectedException thrown = ExpectedException.none();
@Test
- public void installShouldReturnIllegalArgumentExceptionForFirstParameterWithNull()
- throws ArtifactInstallerException
+ public void installShouldReturnIllegalArgumentExceptionForFirstParameterWithNull() throws IllegalArgumentException, ArtifactInstallerException
{
DefaultArtifactInstaller dai = new DefaultArtifactInstaller();
--
To stop receiving notification emails like this one, please contact
khmarbaise@apache.org.