diff --git a/its/core-it-suite/pom.xml b/its/core-it-suite/pom.xml index 774602f262..926e116c43 100644 --- a/its/core-it-suite/pom.xml +++ b/its/core-it-suite/pom.xml @@ -57,6 +57,12 @@ under the License. ITs that don't require to fork Maven can also be run from the IDE using the Maven projects from the workspace if the Maven dependencies are added to the test class path. + + To test with the maven wrapper, you should add the wrapperDistroDir too. + + mvn clean test -Prun-its -Dmaven.repo.local= -DmavenDistro= -DwrapperDistroDir= -DmavenWrapper= + + Tests can pick up the maven.wrapper.distrodir system property to unpack it into their testDir to verify the wrapper. If you're behind a proxy, use the system properties proxy.host, proxy.port, proxy.user, proxy.pass and proxy.nonProxyHosts to specify the required proxy setup for the ITs. Alternatively, set the system property @@ -141,6 +147,17 @@ under the License. guava 16.0 + + org.codehaus.plexus + plexus-archiver + 3.6.0 + + + org.eclipse.sisu + org.eclipse.sisu.plexus + 0.3.4 + provided + @@ -176,6 +193,14 @@ under the License. maven.it.global-settings.dir ${project.build.testOutputDirectory} + + maven.wrapper.distrodir + ${wrapperDistroDir} + + + maven.distro + ${mavenDistro} + @@ -452,6 +477,36 @@ under the License. + + maven-wrapper + + + mavenWrapper + + + + + + org.apache.maven.plugins + maven-install-plugin + 2.5.2 + + + + prepare-wrapper + process-test-resources + + install-file + + + ${mavenWrapper} + + + + + + + emma diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java b/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java index 3f0cbc8d1e..01fdb89dc8 100644 --- a/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java @@ -86,7 +86,7 @@ public class IntegrationTestSuite suite.addTestSuite( MavenITBootstrapTest.class ); /* - * Add tests in reverse alpha order by number below. This makes testing new + * Add tests in reverse order of implementation. This makes testing new * ITs quicker and since it counts down to zero, it's easier to judge how close * the tests are to finishing. Newer tests are also more likely to fail, so this is * a fail fast technique as well. @@ -107,6 +107,7 @@ public class IntegrationTestSuite // ------------------------------------------------------------------------------------------------------------- // suite.addTestSuite( MavenIT0108SnapshotUpdateTest.class ); -- MNG-3137 + suite.addTestSuite( MavenITmng5937MavenWrapper.class ); suite.addTestSuite( MavenITmng4660ResumeFromTest.class ); suite.addTestSuite( MavenITmng4660OutdatedPackagedArtifact.class ); suite.addTestSuite( MavenITmng6759TransitiveDependencyRepositoriesTest.class ); diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5937MavenWrapper.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5937MavenWrapper.java new file mode 100644 index 0000000000..3beb03c4f9 --- /dev/null +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5937MavenWrapper.java @@ -0,0 +1,148 @@ +package org.apache.maven.it; + +/* + * 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.file.Path; +import java.nio.file.Paths; +import java.util.HashMap; +import java.util.Map; + +import org.codehaus.plexus.archiver.zip.ZipUnArchiver; +import org.codehaus.plexus.logging.console.ConsoleLogger; + +/** + * This is a test set for MNG-5937. + * + */ +public class MavenITmng5937MavenWrapper + extends AbstractMavenIntegrationTestCase +{ + private final Path wrapperDistro; + + private final Map envVars; + + private final Path baseDir = Paths.get( "target/test-classes/mng-5937-wrapper" ); + + private ZipUnArchiver zipUnArchiver = new ZipUnArchiver(); + + public MavenITmng5937MavenWrapper() throws Exception + { + super( "[3.7.0,)" ); + + String mavenDist = System.getProperty( "maven.distro" ); + if ( mavenDist == null ) + { + throw new IllegalStateException( "Missing maven.distro to test maven-wrapper" ); + } + + Verifier distInstaller = newVerifier( baseDir.toAbsolutePath().toFile().toString() ); + distInstaller.setSystemProperty( "file", mavenDist ); + distInstaller.setSystemProperty( "groupId", "org.apache.maven" ); + distInstaller.setSystemProperty( "artifactId", "apache-maven" ); + distInstaller.setSystemProperty( "version", getMavenVersion().toString() ); + distInstaller.setSystemProperty( "classifier", "bin" ); + distInstaller.setSystemProperty( "packaging", "zip" ); + distInstaller.executeGoal( "org.apache.maven.plugins:maven-install-plugin:2.5.2:install-file" ); + + String distroValue = System.getProperty( "maven.wrapper.distrodir" ); + if ( distroValue == null ) + { + throw new IllegalStateException( "Missing maven.wrapper.distrodir to test maven-wrapper" ); + } + wrapperDistro = Paths.get( distroValue ); + + String localRepo = System.getProperty("maven.repo.local"); + + envVars = new HashMap<>( 4 ); + envVars.put( "MVNW_REPOURL", Paths.get( localRepo ).toUri().toURL().toString() ); + envVars.put( "MVNW_VERBOSE", "true" ); + String javaHome = System.getenv( "JAVA_HOME" ); + if ( javaHome != null ) + { + // source needs to call the javac executable. + // if JAVA_HOME is not set, ForkedLauncher sets it to java.home, which is the JRE home + envVars.put( "JAVA_HOME", javaHome ); + } + } + + public void testitMNG5937Bin() + throws Exception + { + final File testDir = baseDir.resolve( "bin" ).toFile(); + + unpack( testDir.toPath(), "bin" ); + + envVars.put( "MAVEN_BASEDIR", testDir.getAbsolutePath() ); + + Verifier verifier = newVerifier( testDir.getAbsolutePath() ); + verifier.setAutoclean( false ); + verifier.setDebug( true ); + verifier.executeGoal( "validate", envVars ); + verifier.verifyErrorFreeLog(); + verifier.resetStreams(); + } + + public void testitMNG5937Script() + throws Exception + { + final File testDir = baseDir.resolve( "script" ).toFile(); + + unpack( testDir.toPath(), "script" ); + + envVars.put( "MAVEN_BASEDIR", testDir.getAbsolutePath() ); + + Verifier verifier = newVerifier( testDir.getAbsolutePath() ); + verifier.setAutoclean( false ); + verifier.setDebug( true ); + verifier.executeGoal( "validate", envVars ); + verifier.verifyErrorFreeLog(); + verifier.resetStreams(); + } + + public void testitMNG5937Source() + throws Exception + { + final File testDir = baseDir.resolve( "source" ).toFile(); + + unpack( testDir.toPath(), "source" ); + + envVars.put( "MAVEN_BASEDIR", testDir.getAbsolutePath() ); + + Verifier verifier = newVerifier( testDir.getAbsolutePath() ); + verifier.setAutoclean( false ); + verifier.setDebug( true ); + verifier.executeGoal( "validate", envVars ); + verifier.verifyErrorFreeLog(); + verifier.resetStreams(); + } + + private void unpack( Path target, String classifier ) throws IOException + { + Path distro = wrapperDistro.resolve( "apache-maven-wrapper-" + getMavenVersion() + '-' + classifier + ".zip" ); + + zipUnArchiver.setSourceFile( distro.toFile() ); + zipUnArchiver.setDestDirectory( target.toFile() ); + zipUnArchiver.enableLogging( new ConsoleLogger() ); + + zipUnArchiver.extract(); + } +} diff --git a/its/core-it-suite/src/test/resources/mng-5937-wrapper/bin/pom.xml b/its/core-it-suite/src/test/resources/mng-5937-wrapper/bin/pom.xml new file mode 100644 index 0000000000..5ceadeb27f --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-5937-wrapper/bin/pom.xml @@ -0,0 +1,31 @@ + + + + + + 4.0.0 + + org.apache.maven.its.mng5936 + test + 1 + + Maven Integration Test :: MNG-5979 + + diff --git a/its/core-it-suite/src/test/resources/mng-5937-wrapper/script/pom.xml b/its/core-it-suite/src/test/resources/mng-5937-wrapper/script/pom.xml new file mode 100644 index 0000000000..5ceadeb27f --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-5937-wrapper/script/pom.xml @@ -0,0 +1,31 @@ + + + + + + 4.0.0 + + org.apache.maven.its.mng5936 + test + 1 + + Maven Integration Test :: MNG-5979 + + diff --git a/its/core-it-suite/src/test/resources/mng-5937-wrapper/source/pom.xml b/its/core-it-suite/src/test/resources/mng-5937-wrapper/source/pom.xml new file mode 100644 index 0000000000..5ceadeb27f --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-5937-wrapper/source/pom.xml @@ -0,0 +1,31 @@ + + + + + + 4.0.0 + + org.apache.maven.its.mng5936 + test + 1 + + Maven Integration Test :: MNG-5979 + + diff --git a/its/core-it-support/maven-it-helper/src/main/java/org/apache/maven/it/AbstractMavenIntegrationTestCase.java b/its/core-it-support/maven-it-helper/src/main/java/org/apache/maven/it/AbstractMavenIntegrationTestCase.java index 7e3c42a071..9e0edc44bd 100644 --- a/its/core-it-support/maven-it-helper/src/main/java/org/apache/maven/it/AbstractMavenIntegrationTestCase.java +++ b/its/core-it-support/maven-it-helper/src/main/java/org/apache/maven/it/AbstractMavenIntegrationTestCase.java @@ -130,7 +130,7 @@ public abstract class AbstractMavenIntegrationTestCase * * @return The Maven version or null if unknown. */ - private ArtifactVersion getMavenVersion() + protected final ArtifactVersion getMavenVersion() { if ( mavenVersion == null ) { diff --git a/its/pom.xml b/its/pom.xml index 9ceb300e3a..b15063d2a6 100644 --- a/its/pom.xml +++ b/its/pom.xml @@ -81,7 +81,7 @@ under the License. org.apache.maven.shared maven-verifier - 1.7.1 + 1.7.2 diff --git a/its/run-its.bat b/its/run-its.bat index 7fbbbb39b7..00456942dc 100644 --- a/its/run-its.bat +++ b/its/run-its.bat @@ -19,7 +19,7 @@ @REM How JvZ runs the ITs from a clean slate if it would be on Windows -mvn clean install -Prun-its,embedded -Dmaven.repo.local=%cd%\repo +mvn clean install -U -Prun-its,embedded -Dmaven.repo.local=%cd%\repo @REM If behind a proxy try this..