From f576fefa0a90a011be06b2a74a9d93984d407465 Mon Sep 17 00:00:00 2001 From: tibordigana Date: Tue, 30 Jul 2019 11:47:46 +0200 Subject: [PATCH] [MNG-6725] Skip '.mavenrc' via MAVEN_SKIP_RC=1 and '-Dmaven.skip.rc=true' on child ITs (by default on Jenkins CI). --- its/core-it-suite/pom.xml | 4 +++ .../it/AbstractMavenIntegrationTestCase.java | 27 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/its/core-it-suite/pom.xml b/its/core-it-suite/pom.xml index e1c484d149..444b31c753 100644 --- a/its/core-it-suite/pom.xml +++ b/its/core-it-suite/pom.xml @@ -193,6 +193,10 @@ under the License. maven.it.global-settings.dir ${project.build.testOutputDirectory} + + maven.skip.rc + ${maven.skip.rc} + 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..102f3e7585 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 @@ -42,6 +42,11 @@ import java.util.regex.Pattern; public abstract class AbstractMavenIntegrationTestCase extends TestCase { + /** + * Skips using ".mavenrc" on the system. For more information, see 'MAVEN_SKIP_RC' in $MAVEN_DIST/bin/mvn. + */ + private static final boolean MAVEN_SKIP_RC = isMavenSkipRc(); + /** * Save System.out for progress reports etc. */ @@ -495,6 +500,11 @@ public abstract class AbstractMavenIntegrationTestCase { Verifier verifier = new Verifier( basedir, debug ); + if ( MAVEN_SKIP_RC ) + { + verifier.setEnvironmentVariable( "MAVEN_SKIP_RC", "1" ); + } + verifier.setAutoclean( false ); if ( settings != null ) @@ -601,4 +611,21 @@ public abstract class AbstractMavenIntegrationTestCase { assertCanonicalFileEquals( null, new File( expected ), new File( actual ) ); } + + private static boolean isMavenSkipRc() + { + boolean skipRc = Boolean.getBoolean( "maven.skip.rc" ); + + if ( skipRc ) + { + System.out.println( "SKIPPED - Skipped '.mavenrc'!" ); + } + else + { + System.out.println( "In order to disable '.mavenrc' set the system property 'maven.skip.rc', i.e. " + + "'mvn -Dmaven.skip.rc=true -P run-its verify'." ); + } + + return skipRc; + } }