From a469fd58238533421578265843c603d107981c49 Mon Sep 17 00:00:00 2001 From: rfscholte Date: Sat, 16 Jan 2021 14:41:17 +0100 Subject: [PATCH] Make tests verifiable with at least Maven 3.6.3 --- ...nITmng5572ReactorPluginExtensionsTest.java | 9 +++++- .../maven/it/MavenITmng5937MavenWrapper.java | 29 +++++++++++++------ ...9TransitiveDependencyRepositoriesTest.java | 9 +++++- .../it/AbstractMavenIntegrationTestCase.java | 10 +++++++ its/run-its.bat | 5 ++++ its/run-its.sh | 6 +++- 6 files changed, 56 insertions(+), 12 deletions(-) diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5572ReactorPluginExtensionsTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5572ReactorPluginExtensionsTest.java index f82ee8c0b6..433ebc690f 100644 --- a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5572ReactorPluginExtensionsTest.java +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5572ReactorPluginExtensionsTest.java @@ -61,7 +61,14 @@ public class MavenITmng5572ReactorPluginExtensionsTest verifier.setAutoclean( false ); verifier.executeGoal( "validate" ); verifier.verifyErrorFreeLog(); - verifier.verifyTextInLog( "[WARNING] 'project' uses 'org.apache.maven.its.mng5572:plugin' as extension which is not possible within the same reactor build. This plugin was pulled from the local repository!" ); + if ( getMavenVersion().getMajorVersion() <= 3 ) + { + verifier.verifyTextInLog( "[WARNING] project uses org.apache.maven.its.mng5572:plugin as extensions, which is not possible within the same reactor build. This plugin was pulled from the local repository!" ); + } + else + { + verifier.verifyTextInLog( "[WARNING] 'project' uses 'org.apache.maven.its.mng5572:plugin' as extension which is not possible within the same reactor build. This plugin was pulled from the local repository!" ); + } verifier.resetStreams(); } 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 index 4b47d80070..5f8dff1fb9 100644 --- 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 @@ -54,23 +54,34 @@ public class MavenITmng5937MavenWrapper { super( "[4.0.0-alpha-1,)" ); - 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 ) + + if ( !isSkipped() ) { - // 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 ); + String localRepo = System.getProperty( "maven.repo.local" ); + if ( localRepo != null ) + { + 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 setUp() throws Exception { + if ( isSkipped() ) + { + return; + } + String mavenDist = System.getProperty( "maven.distro" ); if ( StringUtils.isEmpty( mavenDist ) ) { diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6759TransitiveDependencyRepositoriesTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6759TransitiveDependencyRepositoriesTest.java index 21eae3cbda..45a6665a91 100644 --- a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6759TransitiveDependencyRepositoriesTest.java +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6759TransitiveDependencyRepositoriesTest.java @@ -55,7 +55,14 @@ public class MavenITmng6759TransitiveDependencyRepositoriesTest extends Abstract Verifier verifier = newVerifier( dependencyCProjectDir.getAbsolutePath() ); verifier.deleteDirectory( "target" ); - verifier.addCliOption( "-DaltDeploymentRepository=customRepo::" + customRepoUri ); + if ( getMavenVersion().getMajorVersion() <= 3 ) + { + verifier.addCliOption( "-DaltDeploymentRepository=customRepo::default::" + customRepoUri ); + } + else + { + verifier.addCliOption( "-DaltDeploymentRepository=customRepo::" + customRepoUri ); + } verifier.executeGoal( "deploy" ); verifier.verifyErrorFreeLog(); return customRepoUri; 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 bb0a101c54..a30b07b807 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 @@ -202,6 +202,16 @@ public abstract class AbstractMavenIntegrationTestCase } } + /** + * Can be called by version specific setUp calls + * + * @return + */ + protected final boolean isSkipped() + { + return skip; + } + protected void runTest() throws Throwable { diff --git a/its/run-its.bat b/its/run-its.bat index abc501b04c..9bdb4fd9ca 100644 --- a/its/run-its.bat +++ b/its/run-its.bat @@ -37,7 +37,12 @@ CALL :maven && CALL :maven-integration-testing CALL mvn clean verify -DdistributionFileName=${project.artifactId} -f "%_MAVENCODEBASE%" || exit /B :maven-integration-testing +if exist "%_MAVENCODEBASE%\maven-wrapper\target\maven-wrapper.jar" ( CALL mvn clean install -Prun-its,embedded -Dmaven.repo.local="%cd%\repo" -DmavenDistro="%_MAVENCODEBASE%\apache-maven\target\apache-maven-bin.zip" -DwrapperDistroDir="%_MAVENCODEBASE%\apache-maven\target" -DmavenWrapper="%_MAVENCODEBASE%\maven-wrapper\target\maven-wrapper.jar" || exit /B +) +else ( + CALL mvn clean install -Prun-its,embedded,!maven-wrapper -Dmaven.repo.local="%cd%\repo" -DmavenDistro="%_MAVENCODEBASE%\apache-maven\target\apache-maven-bin.zip" || exit /B +) :normalizePath SET _MAVENCODEBASE=%~dpfn1 diff --git a/its/run-its.sh b/its/run-its.sh index 028c39a971..2f85609ade 100755 --- a/its/run-its.sh +++ b/its/run-its.sh @@ -30,7 +30,11 @@ else *) MAVENCODEBASE="$PWD/$MAVENCODEBASE" ;; esac mvn clean verify -P versionlessMavenDist -f "$MAVENCODEBASE" || exit $? - mvn clean install -Prun-its,embedded -Dmaven.repo.local=`pwd`/repo -DmavenDistro="$MAVENCODEBASE/apache-maven/target/apache-maven-bin.zip" -DwrapperDistroDir="$MAVENCODEBASE/apache-maven/target" -DmavenWrapper="$MAVENCODEBASE/maven-wrapper/target/maven-wrapper.jar" + if [ -f "$MAVENCODEBASE/maven-wrapper/target/maven-wrapper.jar" ] ; then + mvn clean install -Prun-its,embedded -Dmaven.repo.local=`pwd`/repo -DmavenDistro="$MAVENCODEBASE/apache-maven/target/apache-maven-bin.zip" -DwrapperDistroDir="$MAVENCODEBASE/apache-maven/target" -DmavenWrapper="$MAVENCODEBASE/maven-wrapper/target/maven-wrapper.jar" || exit $ + else + mvn clean install -Prun-its,embedded,!maven-wrapper -Dmaven.repo.local=`pwd`/repo -DmavenDistro="$MAVENCODEBASE/apache-maven/target/apache-maven-bin.zip" || exit $? + fi fi