Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[5937] Maven-Wrapper for unified project environments
- Loading branch information
Showing
9 changed files
with
301 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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=<path-to-local-repo> -DmavenDistro=<path-to-bin-archive> -DwrapperDistroDir=<path-to-wrapper-distro-directory> -DmavenWrapper=<path-to-wrapper-jar> | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
rfscholte
Author
Contributor
|
||
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. | |
<artifactId>guava</artifactId> | ||
<version>16.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.codehaus.plexus</groupId> | ||
<artifactId>plexus-archiver</artifactId> | ||
<version>3.6.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.sisu</groupId> | ||
<artifactId>org.eclipse.sisu.plexus</artifactId> | ||
<version>0.3.4</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
|
@@ -176,6 +193,14 @@ under the License. | |
<name>maven.it.global-settings.dir</name> | ||
<value>${project.build.testOutputDirectory}</value> | ||
</property> | ||
<property> | ||
<name>maven.wrapper.distrodir</name> | ||
<value>${wrapperDistroDir}</value> | ||
</property> | ||
<property> | ||
<name>maven.distro</name> | ||
<value>${mavenDistro}</value> | ||
</property> | ||
</systemProperties> | ||
</configuration> | ||
</plugin> | ||
|
@@ -452,6 +477,36 @@ under the License. | |
</plugins> | ||
</build> | ||
</profile> | ||
<profile> | ||
<id>maven-wrapper</id> | ||
<activation> | ||
<property> | ||
<name>mavenWrapper</name> | ||
</property> | ||
</activation> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-install-plugin</artifactId> | ||
<version>2.5.2</version> | ||
<executions> | ||
<!-- install, so it can be called via a URL --> | ||
<execution> | ||
<id>prepare-wrapper</id> | ||
<phase>process-test-resources</phase> | ||
<goals> | ||
<goal>install-file</goal> | ||
</goals> | ||
<configuration> | ||
<file>${mavenWrapper}</file> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
<profile> | ||
<id>emma</id> | ||
<properties> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
148 changes: 148 additions & 0 deletions
148
core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5937MavenWrapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <a href="https://issues.apache.org/jira/browse/MNG-5937">MNG-5937</a>. | ||
* | ||
*/ | ||
public class MavenITmng5937MavenWrapper | ||
extends AbstractMavenIntegrationTestCase | ||
{ | ||
private final Path wrapperDistro; | ||
|
||
private final Map<String,String> 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(); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
core-it-suite/src/test/resources/mng-5937-wrapper/bin/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?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> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>org.apache.maven.its.mng5936</groupId> | ||
<artifactId>test</artifactId> | ||
<version>1</version> | ||
|
||
<name>Maven Integration Test :: MNG-5979</name> | ||
|
||
</project> |
31 changes: 31 additions & 0 deletions
31
core-it-suite/src/test/resources/mng-5937-wrapper/script/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?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> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>org.apache.maven.its.mng5936</groupId> | ||
<artifactId>test</artifactId> | ||
<version>1</version> | ||
|
||
<name>Maven Integration Test :: MNG-5979</name> | ||
|
||
</project> |
31 changes: 31 additions & 0 deletions
31
core-it-suite/src/test/resources/mng-5937-wrapper/source/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?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> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>org.apache.maven.its.mng5936</groupId> | ||
<artifactId>test</artifactId> | ||
<version>1</version> | ||
|
||
<name>Maven Integration Test :: MNG-5979</name> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Following README.md to run
mvn clean install -Prun-its -Dmaven.repo.local=
pwd/repo -DmavenDistro=/path/to/apache-maven-dist.zip
, I got below error:Looks that you've changed the command, but haven't updated it in README. Can you help to update it, or point me to the correct command? Do I have to specify wrapper distro dir?