Author: khmarbaise
Date: Sun Aug 20 12:58:09 2017
New Revision: 1805552
URL: http://svn.apache.org/viewvc?rev=1805552&view=rev
Log:
[MSHARED-656] Make integration testing for different Maven versions possible
o Added integration testing possibility to the project.
Currently not very convenient but works and helps.
Added:
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/it/
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/it/maven-artifact-installer-plugin/
(with props)
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/it/maven-artifact-installer-plugin/pom.xml
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/it/maven-artifact-installer-plugin/src/
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/it/maven-artifact-installer-plugin/src/main/
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/it/maven-artifact-installer-plugin/src/main/java/
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/it/maven-artifact-installer-plugin/src/main/java/org/
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/it/maven-artifact-installer-plugin/src/main/java/org/apache/
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/it/maven-artifact-installer-plugin/src/main/java/org/apache/maven/
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/it/maven-artifact-installer-plugin/src/main/java/org/apache/maven/plugin/
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/it/maven-artifact-installer-plugin/src/main/java/org/apache/maven/plugin/artifact/
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/it/maven-artifact-installer-plugin/src/main/java/org/apache/maven/plugin/artifact/installer/
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/it/maven-artifact-installer-plugin/src/main/java/org/apache/maven/plugin/artifact/installer/ArtifactInstallerMojo.java
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/it/maven-artifact-installer-plugin/src/test/
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/it/maven-artifact-installer-plugin/src/test/java/
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/it/maven-artifact-installer-plugin/src/test/java/org/
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/it/maven-artifact-installer-plugin/src/test/java/org/apache/
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/it/maven-artifact-installer-plugin/src/test/java/org/apache/maven/
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/it/maven-artifact-installer-plugin/src/test/java/org/apache/maven/plugin/
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/it/maven-artifact-installer-plugin/src/test/java/org/apache/maven/plugin/artifact/
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/it/maven-artifact-installer-plugin/src/test/java/org/apache/maven/plugin/artifact/installer/
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/it/maven-artifact-installer-plugin/src/test/java/org/apache/maven/plugin/artifact/installer/ArtifactInstallerTest.java
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/it/maven-artifact-installer-plugin/src/test/java/org/apache/maven/plugin/artifact/installer/component/
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/it/maven-artifact-installer-plugin/src/test/projects/
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/it/maven-artifact-installer-plugin/src/test/projects/example/
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/it/maven-artifact-installer-plugin/src/test/projects/example/pom.xml
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/it/settings.xml
Modified:
maven/shared/branches/maven-artifact-transfer-MSHARED-656/pom.xml
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/main/java/org/apache/maven/shared/artifact/install/ArtifactInstaller.java
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/main/java/org/apache/maven/shared/artifact/install/internal/DefaultArtifactInstaller.java
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/main/java/org/apache/maven/shared/artifact/install/internal/Maven31ArtifactInstaller.java
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/main/java/org/apache/maven/shared/project/deploy/ProjectDeployer.java
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/main/java/org/apache/maven/shared/project/install/ProjectInstaller.java
Modified: maven/shared/branches/maven-artifact-transfer-MSHARED-656/pom.xml
URL:
http://svn.apache.org/viewvc/maven/shared/branches/maven-artifact-transfer-MSHARED-656/pom.xml?rev=1805552&r1=1805551&r2=1805552&view=diff
==============================================================================
--- maven/shared/branches/maven-artifact-transfer-MSHARED-656/pom.xml (original)
+++ maven/shared/branches/maven-artifact-transfer-MSHARED-656/pom.xml Sun Aug
20 12:58:09 2017
@@ -1,23 +1,25 @@
<?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
+ or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
+ 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
+ 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
+ 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">
+<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>
@@ -28,7 +30,7 @@
</parent>
<artifactId>maven-artifact-transfer</artifactId>
- <version>0.9.2-SNAPSHOT</version>
+ <version>0.10.0-SNAPSHOT</version>
<name>Apache Maven Artifact Transfer</name>
<description>An API to install, deploy and resolving artifacts with Maven
3</description>
@@ -50,6 +52,9 @@
</site>
</distributionManagement>
+ <properties>
+ <javaVersion>7</javaVersion>
+ </properties>
<build>
<plugins>
<plugin>
@@ -98,6 +103,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>
@@ -141,6 +147,7 @@
</execution>
</executions>
</plugin>
+
</plugins>
</build>
@@ -172,7 +179,7 @@
<artifactId>plexus-utils</artifactId>
<version>3.1.0</version>
</dependency>
-
+
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
@@ -232,6 +239,13 @@
<version>4.11</version>
<scope>test</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <version>2.7.12</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<pluginRepositories>
@@ -247,4 +261,67 @@
</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>
+ </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>
Propchange:
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/it/maven-artifact-installer-plugin/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sun Aug 20 12:58:09 2017
@@ -0,0 +1,4 @@
+target
+.settings
+.project
+.classpath
Added:
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/it/maven-artifact-installer-plugin/pom.xml
URL:
http://svn.apache.org/viewvc/maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/it/maven-artifact-installer-plugin/pom.xml?rev=1805552&view=auto
==============================================================================
---
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/it/maven-artifact-installer-plugin/pom.xml
(added)
+++
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/it/maven-artifact-installer-plugin/pom.xml
Sun Aug 20 12:58:09 2017
@@ -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>
Added:
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/it/maven-artifact-installer-plugin/src/main/java/org/apache/maven/plugin/artifact/installer/ArtifactInstallerMojo.java
URL:
http://svn.apache.org/viewvc/maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/it/maven-artifact-installer-plugin/src/main/java/org/apache/maven/plugin/artifact/installer/ArtifactInstallerMojo.java?rev=1805552&view=auto
==============================================================================
---
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/it/maven-artifact-installer-plugin/src/main/java/org/apache/maven/plugin/artifact/installer/ArtifactInstallerMojo.java
(added)
+++
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/it/maven-artifact-installer-plugin/src/main/java/org/apache/maven/plugin/artifact/installer/ArtifactInstallerMojo.java
Sun Aug 20 12:58:09 2017
@@ -0,0 +1,111 @@
+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.util.Arrays;
+import java.util.Collection;
+
+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;
+
+/**
+ */
+@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 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 );
+
+ 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 );
+ artifactWithClassifier.setFile( tmpFile );
+
+ 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 );
+ }
+
+ }
+
+}
Added:
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/it/maven-artifact-installer-plugin/src/test/java/org/apache/maven/plugin/artifact/installer/ArtifactInstallerTest.java
URL:
http://svn.apache.org/viewvc/maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/it/maven-artifact-installer-plugin/src/test/java/org/apache/maven/plugin/artifact/installer/ArtifactInstallerTest.java?rev=1805552&view=auto
==============================================================================
---
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/it/maven-artifact-installer-plugin/src/test/java/org/apache/maven/plugin/artifact/installer/ArtifactInstallerTest.java
(added)
+++
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/it/maven-artifact-installer-plugin/src/test/java/org/apache/maven/plugin/artifact/installer/ArtifactInstallerTest.java
Sun Aug 20 12:58:09 2017
@@ -0,0 +1,79 @@
+package org.apache.maven.plugin.artifact.installer;
+
+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-component-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() );
+ assertTrue( new File( localRepo, "GROUPID-" + mvnVersion
+ + "/ARTIFACTID/VERSION/ARTIFACTID-VERSION-CLASSIFIER.EXTENSION"
).exists() );
+ assertTrue( new File( localRepo, "GROUPID-" + mvnVersion +
"/ARTIFACTID/maven-metadata-local.xml" ).exists() ); // ??
+
+ }
+}
\ No newline at end of file
Added:
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/it/maven-artifact-installer-plugin/src/test/projects/example/pom.xml
URL:
http://svn.apache.org/viewvc/maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/it/maven-artifact-installer-plugin/src/test/projects/example/pom.xml?rev=1805552&view=auto
==============================================================================
---
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/it/maven-artifact-installer-plugin/src/test/projects/example/pom.xml
(added)
+++
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/it/maven-artifact-installer-plugin/src/test/projects/example/pom.xml
Sun Aug 20 12:58:09 2017
@@ -0,0 +1,50 @@
+<?xml version='1.0' encoding='UTF-8'?>
+
+<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>
Added:
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/it/settings.xml
URL:
http://svn.apache.org/viewvc/maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/it/settings.xml?rev=1805552&view=auto
==============================================================================
---
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/it/settings.xml
(added)
+++
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/it/settings.xml
Sun Aug 20 12:58:09 2017
@@ -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>
Modified:
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/main/java/org/apache/maven/shared/artifact/install/ArtifactInstaller.java
URL:
http://svn.apache.org/viewvc/maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/main/java/org/apache/maven/shared/artifact/install/ArtifactInstaller.java?rev=1805552&r1=1805551&r2=1805552&view=diff
==============================================================================
---
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/main/java/org/apache/maven/shared/artifact/install/ArtifactInstaller.java
(original)
+++
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/main/java/org/apache/maven/shared/artifact/install/ArtifactInstaller.java
Sun Aug 20 12:58:09 2017
@@ -33,11 +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 <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}.
Modified:
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/main/java/org/apache/maven/shared/artifact/install/internal/DefaultArtifactInstaller.java
URL:
http://svn.apache.org/viewvc/maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/main/java/org/apache/maven/shared/artifact/install/internal/DefaultArtifactInstaller.java?rev=1805552&r1=1805551&r2=1805552&view=diff
==============================================================================
---
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/main/java/org/apache/maven/shared/artifact/install/internal/DefaultArtifactInstaller.java
(original)
+++
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/main/java/org/apache/maven/shared/artifact/install/internal/DefaultArtifactInstaller.java
Sun Aug 20 12:58:09 2017
@@ -46,8 +46,21 @@ public class DefaultArtifactInstaller
@Override
public void install( ProjectBuildingRequest request, Collection<Artifact>
mavenArtifacts )
- throws ArtifactInstallerException
+ throws ArtifactInstallerException, IllegalArgumentException
{
+ if ( request == null )
+ {
+ throw new IllegalArgumentException( "The parameter request is not
allowed to be null." );
+ }
+ if ( mavenArtifacts == null )
+ {
+ throw new IllegalArgumentException( "The parameter mavenArtifacts
is not allowed to be null." );
+ }
+ if ( mavenArtifacts.isEmpty() )
+ {
+ throw new IllegalArgumentException( "The collection mavenArtifacts
is not allowed to be empty." );
+ }
+
try
{
String hint = isMaven31() ? "maven31" : "maven3";
@@ -61,11 +74,32 @@ public class DefaultArtifactInstaller
throw new ArtifactInstallerException( e.getMessage(), e );
}
}
-
+
@Override
public void install( ProjectBuildingRequest request, File localRepositry,
Collection<Artifact> mavenArtifacts )
throws ArtifactInstallerException
{
+ if ( request == null )
+ {
+ throw new IllegalArgumentException( "The parameter request is not
allowed to be null." );
+ }
+ if ( localRepositry == null )
+ {
+ throw new IllegalArgumentException( "The parameter localRepository
is not allowed to be null." );
+ }
+ if ( !localRepositry.isDirectory() )
+ {
+ throw new IllegalArgumentException( "The parameter localRepository
must be a directory." );
+ }
+ if ( mavenArtifacts == null )
+ {
+ throw new IllegalArgumentException( "The parameter mavenArtifacts
is not allowed to be null." );
+ }
+ if ( mavenArtifacts.isEmpty() )
+ {
+ throw new IllegalArgumentException( "The collection mavenArtifacts
is not allowed to be empty." );
+ }
+
try
{
String hint = isMaven31() ? "maven31" : "maven3";
Modified:
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/main/java/org/apache/maven/shared/artifact/install/internal/Maven31ArtifactInstaller.java
URL:
http://svn.apache.org/viewvc/maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/main/java/org/apache/maven/shared/artifact/install/internal/Maven31ArtifactInstaller.java?rev=1805552&r1=1805551&r2=1805552&view=diff
==============================================================================
---
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/main/java/org/apache/maven/shared/artifact/install/internal/Maven31ArtifactInstaller.java
(original)
+++
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/main/java/org/apache/maven/shared/artifact/install/internal/Maven31ArtifactInstaller.java
Sun Aug 20 12:58:09 2017
@@ -46,7 +46,6 @@ import org.eclipse.aether.util.artifact.
public class Maven31ArtifactInstaller
implements ArtifactInstaller
{
-
@Requirement
private RepositorySystem repositorySystem;
Modified:
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/main/java/org/apache/maven/shared/project/deploy/ProjectDeployer.java
URL:
http://svn.apache.org/viewvc/maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/main/java/org/apache/maven/shared/project/deploy/ProjectDeployer.java?rev=1805552&r1=1805551&r2=1805552&view=diff
==============================================================================
---
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/main/java/org/apache/maven/shared/project/deploy/ProjectDeployer.java
(original)
+++
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/main/java/org/apache/maven/shared/project/deploy/ProjectDeployer.java
Sun Aug 20 12:58:09 2017
@@ -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;
Modified:
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/main/java/org/apache/maven/shared/project/install/ProjectInstaller.java
URL:
http://svn.apache.org/viewvc/maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/main/java/org/apache/maven/shared/project/install/ProjectInstaller.java?rev=1805552&r1=1805551&r2=1805552&view=diff
==============================================================================
---
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/main/java/org/apache/maven/shared/project/install/ProjectInstaller.java
(original)
+++
maven/shared/branches/maven-artifact-transfer-MSHARED-656/src/main/java/org/apache/maven/shared/project/install/ProjectInstaller.java
Sun Aug 20 12:58:09 2017
@@ -71,6 +71,8 @@ public interface ProjectInstaller
* @throws ArtifactInstallerException In case of problems to install
artifacts.
* @throws NoFileAssignedException If no file has been assigned to the
project.
*/
+ // TODO: Think about null check for projectBuildingRequest?
+ // TODO: Think about null check for projectInstallerRequest?
void install( ProjectBuildingRequest projectBuildingRequest,
ProjectInstallerRequest projectInstallerRequest )
throws IOException, ArtifactInstallerException,
NoFileAssignedException;