Merge branch 'revert-MNG-6772' of https://gitbox.apache.org/repos/asf/maven-integration-testing into revert-MNG-6772
diff --git a/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java b/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
index 027587f..337e1a9 100644
--- a/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
+++ b/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
@@ -106,6 +106,7 @@
// Tests that don't run stable and need to be fixed
// -------------------------------------------------------------------------------------------------------------
// suite.addTestSuite( MavenIT0108SnapshotUpdateTest.class ); -- MNG-3137
+ suite.addTestSuite( MavenITmng7051OptionalProfileActivationTest.class );
suite.addTestSuite( MavenITmng6957BuildConsumer.class );
suite.addTestSuite( MavenITmng7045DropUselessAndOutdatedCdiApiTest.class );
suite.addTestSuite( MavenITmng6566ExecuteAnnotationShouldNotReExecuteGoalsTest.class );
diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenIT0051ReleaseProfileTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenIT0051ReleaseProfileTest.java
index ad951d3..5d33200 100644
--- a/core-it-suite/src/test/java/org/apache/maven/it/MavenIT0051ReleaseProfileTest.java
+++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenIT0051ReleaseProfileTest.java
@@ -30,7 +30,7 @@
public MavenIT0051ReleaseProfileTest()
{
- super( "(2.0.2,)" );
+ super( "(2.0.2,4.0.0-alpha-1)" );
}
/**
diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng2309ProfileInjectionOrderTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng2309ProfileInjectionOrderTest.java
index 2f46491..7666aa4 100644
--- a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng2309ProfileInjectionOrderTest.java
+++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng2309ProfileInjectionOrderTest.java
@@ -22,7 +22,6 @@
import java.io.File;
import java.util.Properties;
-import org.apache.maven.it.Verifier;
import org.apache.maven.it.util.ResourceExtractor;
/**
@@ -52,10 +51,19 @@
verifier.setAutoclean( false );
verifier.addCliOption( "--settings" );
verifier.addCliOption( "settings.xml" );
- verifier.addCliOption( "-P"
- + "pom-a,pom-b,pom-e,pom-c,pom-d"
- + ",profiles-a,profiles-b,profiles-e,profiles-c,profiles-d"
- + ",settings-a,settings-b,settings-e,settings-c,settings-d" );
+ if ( matchesVersionRange( "[4.0.0-alpha-1,)" ) )
+ {
+ verifier.addCliOption( "-P"
+ + "pom-a,pom-b,pom-e,pom-c,pom-d"
+ + ",settings-a,settings-b,settings-e,settings-c,settings-d" );
+ }
+ else
+ {
+ verifier.addCliOption( "-P"
+ + "pom-a,pom-b,pom-e,pom-c,pom-d"
+ + ",profiles-a,profiles-b,profiles-e,profiles-c,profiles-d"
+ + ",settings-a,settings-b,settings-e,settings-c,settings-d" );
+ }
verifier.executeGoal( "validate" );
verifier.verifyErrorFreeLog();
verifier.resetStreams();
diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3641ProfileActivationWarningTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3641ProfileActivationWarningTest.java
index 11fc0ef..778c662 100644
--- a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3641ProfileActivationWarningTest.java
+++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3641ProfileActivationWarningTest.java
@@ -35,7 +35,7 @@
public MavenITmng3641ProfileActivationWarningTest()
{
- super( "[2.0.11,2.1.0-M1),[2.1.0,)" ); // only test in 2.0.11+, 2.1.0+
+ super( "[2.0.11,2.1.0-M1),[2.1.0,4.0.0-alpha-1)" ); // only test in 2.0.11+, 2.1.0+
}
public void testitMNG3641()
diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3732ActiveProfilesTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3732ActiveProfilesTest.java
index bdf95f6..b47f300 100644
--- a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3732ActiveProfilesTest.java
+++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3732ActiveProfilesTest.java
@@ -56,7 +56,14 @@
verifier.deleteDirectory( "target" );
verifier.addCliOption( "--settings" );
verifier.addCliOption( "settings.xml" );
- verifier.addCliOption( "-Ppom,profiles,settings" );
+ if ( matchesVersionRange( "[4.0.0-alpha-1,)" ) )
+ {
+ verifier.addCliOption( "-Ppom,settings" );
+ }
+ else
+ {
+ verifier.addCliOption( "-Ppom,profiles,settings" );
+ }
verifier.executeGoal( "validate" );
verifier.verifyErrorFreeLog();
verifier.resetStreams();
diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4106InterpolationUsesDominantProfileTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4106InterpolationUsesDominantProfileTest.java
index 83f45ba..28a4afe 100644
--- a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4106InterpolationUsesDominantProfileTest.java
+++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4106InterpolationUsesDominantProfileTest.java
@@ -54,7 +54,14 @@
verifier.setAutoclean( false );
verifier.addCliOption( "--settings" );
verifier.addCliOption( "settings.xml" );
- verifier.addCliOption( "-Ppom-a,pom-b,profiles-a,profiles-b,settings-a,settings-b" );
+ if ( matchesVersionRange( "[4.0.0-alpha-1,)" ) )
+ {
+ verifier.addCliOption( "-Ppom-a,pom-b,settings-a,settings-b" );
+ }
+ else
+ {
+ verifier.addCliOption( "-Ppom-a,pom-b,profiles-a,profiles-b,settings-a,settings-b" );
+ }
verifier.executeGoal( "validate" );
verifier.verifyErrorFreeLog();
verifier.resetStreams();
diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4660ResumeFromTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4660ResumeFromTest.java
index 2d3191d..e008c2f 100644
--- a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4660ResumeFromTest.java
+++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4660ResumeFromTest.java
@@ -38,7 +38,7 @@
/**
* Test that the --resume-from flag resolves dependencies inside the same Maven project
* without having them installed first.
- * This test case uses the target/classes folder of module-a, for the situation where
+ * This test case uses the target/classes directory of module-a, for the situation where
* module-a has not been packaged.
*/
public void testShouldResolveOutputDirectoryFromEarlierBuild() throws Exception
diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6256SpecialCharsAlternatePOMLocation.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6256SpecialCharsAlternatePOMLocation.java
index 5038113..027c1d0 100644
--- a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6256SpecialCharsAlternatePOMLocation.java
+++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6256SpecialCharsAlternatePOMLocation.java
@@ -26,7 +26,7 @@
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-6256">MNG-6256</a>: check that directories
* passed via <code>-f/--file</code> containing special characters do not break the script. E.g
- * <code>-f "folderWithClosing)Bracket/pom.xml"</code>.
+ * <code>-f "directoryWithClosing)Bracket/pom.xml"</code>.
*/
public class MavenITmng6256SpecialCharsAlternatePOMLocation
extends AbstractMavenIntegrationTestCase
@@ -42,23 +42,23 @@
}
/**
- * check script is working when path to POM is set to <code>folder-with- -space</code>
+ * check script is working when path to POM is set to <code>directory-with- -space</code>
*/
- public void testFolderWithSpace()
+ public void testDirectoryWithSpace()
throws Exception
{
- runWithMvnFileLongOption( "folder-with- -space" );
- runWithMvnFileShortOption( "folder-with- -space" );
+ runWithMvnFileLongOption( "directory-with- -space" );
+ runWithMvnFileShortOption( "directory-with- -space" );
}
/**
- * check script is working when path to POM is set to <code>folder-with-)-closing-bracket</code>
+ * check script is working when path to POM is set to <code>directory-with-)-closing-bracket</code>
*/
- public void testFolderWithClosingBracket()
+ public void testDirectoryWithClosingBracket()
throws Exception
{
- runWithMvnFileLongOption( "folder-with-)-closing-bracket" );
- runWithMvnFileShortOption( "folder-with-)-closing-bracket" );
+ runWithMvnFileLongOption( "directory-with-)-closing-bracket" );
+ runWithMvnFileShortOption( "directory-with-)-closing-bracket" );
}
private void runWithMvnFileLongOption( String subDir )
diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng7051OptionalProfileActivationTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng7051OptionalProfileActivationTest.java
new file mode 100644
index 0000000..6682ada
--- /dev/null
+++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng7051OptionalProfileActivationTest.java
@@ -0,0 +1,128 @@
+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 org.apache.maven.it.util.ResourceExtractor;
+
+import java.io.File;
+import java.io.IOException;
+
+public class MavenITmng7051OptionalProfileActivationTest
+ extends AbstractMavenIntegrationTestCase
+{
+ private static final String PROJECT_PATH = "/mng-7051-optional-profile-activation";
+
+ public MavenITmng7051OptionalProfileActivationTest()
+ {
+ super( "[4.0.0-alpha-1,)" );
+ }
+
+ /**
+ * This test verifies that activating a non-existing profile breaks the build.
+ */
+ public void testActivatingNonExistingProfileBreaks() throws IOException, VerificationException
+ {
+ final File projectDir = ResourceExtractor.simpleExtractResources( getClass(), PROJECT_PATH );
+ final Verifier verifier = newVerifier( projectDir.getAbsolutePath() );
+
+ verifier.addCliOption( "-P" );
+ verifier.addCliOption( "non-existing-profile" );
+ verifier.setLogFileName( "test-breaking.txt" );
+
+ try
+ {
+ verifier.executeGoal( "validate" );
+ fail( "Activated a non-existing profile without ? prefix should break the build, but it didn't." );
+ }
+ catch ( VerificationException ve )
+ {
+ // Inspect the reason why the build broke.
+ verifier.verifyTextInLog( "[ERROR] The requested profiles [non-existing-profile] could not be activated or deactivated because they do not exist." );
+ }
+ }
+
+ /**
+ * This test verifies that activating a non-existing profile does not break the build when it is prefixed with <strong>?</strong>.
+ */
+ public void testActivatingNonExistingProfileWithQuestionMarkDoesNotBreak() throws IOException, VerificationException
+ {
+ final File projectDir = ResourceExtractor.simpleExtractResources( getClass(), PROJECT_PATH );
+ final Verifier verifier = newVerifier( projectDir.getAbsolutePath() );
+
+ verifier.addCliOption( "-P" );
+ verifier.addCliOption( "?non-existing-profile" );
+ verifier.setLogFileName( "test-non-breaking.txt" );
+
+ verifier.executeGoal( "validate" );
+ verifier.verifyErrorFreeLog();
+ verifier.verifyTextInLog( "[WARNING] The requested optional profiles [non-existing-profile] could not be activated or deactivated because they do not exist." );
+ }
+
+ /**
+ * This test verifies that activating both an existing and a non-existing profile does not break the build when it the latter is prefixed with <strong>?</strong>.
+ */
+ public void testActivatingExistingAndNonExistingProfiles() throws IOException, VerificationException
+ {
+ final File projectDir = ResourceExtractor.simpleExtractResources( getClass(), PROJECT_PATH );
+ final Verifier verifier = newVerifier( projectDir.getAbsolutePath() );
+
+ verifier.addCliOption( "-P" );
+ verifier.addCliOption( "?non-existing-profile,existing" );
+ verifier.setLogFileName( "test-non-breaking-mixed.txt" );
+
+ verifier.executeGoal( "validate" );
+ verifier.verifyErrorFreeLog();
+ verifier.verifyTextInLog( "[WARNING] The requested optional profiles [non-existing-profile] could not be activated or deactivated because they do not exist." );
+ }
+
+ /**
+ * This test verifies that deactivating a non-existing profile does not break the build when it is prefixed with <strong>?</strong>.
+ */
+ public void testDeactivatingNonExistingProfileWithQuestionMarkDoesNotBreak() throws IOException, VerificationException
+ {
+ final File projectDir = ResourceExtractor.simpleExtractResources( getClass(), PROJECT_PATH );
+ final Verifier verifier = newVerifier( projectDir.getAbsolutePath() );
+
+ verifier.addCliOption( "-P" );
+ verifier.addCliOption( "!?non-existing-profile" );
+ verifier.setLogFileName( "test-deactivating-non-breaking.txt" );
+
+ verifier.executeGoal( "validate" );
+ verifier.verifyErrorFreeLog();
+ verifier.verifyTextInLog( "[WARNING] The requested optional profiles [non-existing-profile] could not be activated or deactivated because they do not exist." );
+ }
+
+ /**
+ * This test verifies that deactivating both an existing and a non-existing profile does not break the build when it the latter is prefixed with <strong>?</strong>.
+ */
+ public void testDeactivatingExistingAndNonExistingProfiles() throws IOException, VerificationException
+ {
+ final File projectDir = ResourceExtractor.simpleExtractResources( getClass(), PROJECT_PATH );
+ final Verifier verifier = newVerifier( projectDir.getAbsolutePath() );
+
+ verifier.addCliOption( "-P" );
+ verifier.addCliOption( "!?non-existing-profile,!existing" );
+ verifier.setLogFileName( "test-deactivating-non-breaking-mixed.txt" );
+
+ verifier.executeGoal( "validate" );
+ verifier.verifyErrorFreeLog();
+ verifier.verifyTextInLog( "[WARNING] The requested optional profiles [non-existing-profile] could not be activated or deactivated because they do not exist." );
+ }
+}
diff --git a/core-it-suite/src/test/resources/mng-6256-special-chars-alternate-pom-location/folder-with- -space/pom.xml b/core-it-suite/src/test/resources/mng-6256-special-chars-alternate-pom-location/directory-with- -space/pom.xml
similarity index 100%
rename from core-it-suite/src/test/resources/mng-6256-special-chars-alternate-pom-location/folder-with- -space/pom.xml
rename to core-it-suite/src/test/resources/mng-6256-special-chars-alternate-pom-location/directory-with- -space/pom.xml
diff --git "a/core-it-suite/src/test/resources/mng-6256-special-chars-alternate-pom-location/folder-with-\051-closing-bracket/pom.xml" "b/core-it-suite/src/test/resources/mng-6256-special-chars-alternate-pom-location/directory-with-\051-closing-bracket/pom.xml"
similarity index 100%
rename from "core-it-suite/src/test/resources/mng-6256-special-chars-alternate-pom-location/folder-with-\051-closing-bracket/pom.xml"
rename to "core-it-suite/src/test/resources/mng-6256-special-chars-alternate-pom-location/directory-with-\051-closing-bracket/pom.xml"
diff --git a/core-it-suite/src/test/resources/mng-7051-optional-profile-activation/pom.xml b/core-it-suite/src/test/resources/mng-7051-optional-profile-activation/pom.xml
new file mode 100644
index 0000000..0963c0b
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-7051-optional-profile-activation/pom.xml
@@ -0,0 +1,37 @@
+<?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>
+
+ <groupId>org.apache.maven.its.mng7051</groupId>
+ <artifactId>profile-selection</artifactId>
+ <version>1.0</version>
+
+ <profiles>
+ <profile>
+ <id>existing</id>
+ </profile>
+ </profiles>
+
+</project>
\ No newline at end of file
diff --git a/core-it-support/maven-it-helper/src/main/java/org/apache/maven/it/AbstractMavenIntegrationTestCase.java b/core-it-support/maven-it-helper/src/main/java/org/apache/maven/it/AbstractMavenIntegrationTestCase.java
index c7f5c33..12f1443 100644
--- a/core-it-support/maven-it-helper/src/main/java/org/apache/maven/it/AbstractMavenIntegrationTestCase.java
+++ b/core-it-support/maven-it-helper/src/main/java/org/apache/maven/it/AbstractMavenIntegrationTestCase.java
@@ -624,10 +624,10 @@
return verifier;
}
- private boolean hasDotMvnSubfolder( Path path )
+ private boolean hasDotMvnSubDirectory( Path path )
{
- final Path probablySubfolder = path.resolve( ".mvn" );
- return Files.exists( probablySubfolder ) && Files.isDirectory( probablySubfolder );
+ final Path probablySubDirectory = path.resolve( ".mvn" );
+ return Files.exists( probablySubDirectory ) && Files.isDirectory( probablySubDirectory );
}
private String findMultiModuleProjectDirectory( String basedir )
@@ -643,7 +643,7 @@
while ( !fileSystemRoots.contains( path ) )
{
- if ( hasDotMvnSubfolder( path ) )
+ if ( hasDotMvnSubDirectory( path ) )
{
result = path;
break;
diff --git a/core-it-support/maven-it-sample-archetype/src/main/resources/archetype-resources/src/test/java/MavenITmngXXXXDescriptionOfProblemTest.java b/core-it-support/maven-it-sample-archetype/src/main/resources/archetype-resources/src/test/java/MavenITmngXXXXDescriptionOfProblemTest.java
index 50aa5c8..1392707 100644
--- a/core-it-support/maven-it-sample-archetype/src/main/resources/archetype-resources/src/test/java/MavenITmngXXXXDescriptionOfProblemTest.java
+++ b/core-it-support/maven-it-sample-archetype/src/main/resources/archetype-resources/src/test/java/MavenITmngXXXXDescriptionOfProblemTest.java
@@ -32,10 +32,10 @@
/**
* This is a sample integration test. The IT tests typically
* operate by having a sample project in the
- * /src/test/resources folder along with a junit test like
+ * /src/test/resources directory along with a junit test like
* this one. The junit test uses the verifier (which uses
* the invoker) to invoke a new instance of Maven on the
- * project in the resources folder. It then checks the
+ * project in the resources directory. It then checks the
* results. This is a non-trivial example that shows two
* phases. See more information inline in the code.
*
diff --git a/core-it-support/maven-it-sample/src/test/java/org/apache/maven/it/MavenITmngXXXXDescriptionOfProblemTest.java b/core-it-support/maven-it-sample/src/test/java/org/apache/maven/it/MavenITmngXXXXDescriptionOfProblemTest.java
index 311d02b..b4e1079 100644
--- a/core-it-support/maven-it-sample/src/test/java/org/apache/maven/it/MavenITmngXXXXDescriptionOfProblemTest.java
+++ b/core-it-support/maven-it-sample/src/test/java/org/apache/maven/it/MavenITmngXXXXDescriptionOfProblemTest.java
@@ -29,10 +29,10 @@
/**
* This is a sample integration test. The IT tests typically
* operate by having a sample project in the
- * /src/test/resources folder along with a junit test like
+ * /src/test/resources directory along with a junit test like
* this one. The junit test uses the verifier (which uses
* the invoker) to invoke a new instance of Maven on the
- * project in the resources folder. It then checks the
+ * project in the resources directory. It then checks the
* results. This is a non-trivial example that shows two
* phases. See more information inline in the code.
*
diff --git a/run-its.bat b/run-its.bat
index 741d5c5..9bdb4fd 100644
--- a/run-its.bat
+++ b/run-its.bat
@@ -34,7 +34,7 @@
:: ========== FUNCTIONS ==========
:maven
- CALL mvn verify -DdistributionFileName=${project.artifactId} -f "%_MAVENCODEBASE%" || exit /B
+ CALL mvn clean verify -DdistributionFileName=${project.artifactId} -f "%_MAVENCODEBASE%" || exit /B
:maven-integration-testing
if exist "%_MAVENCODEBASE%\maven-wrapper\target\maven-wrapper.jar" (
diff --git a/run-its.sh b/run-its.sh
index 5f84d2d..028c39a 100755
--- a/run-its.sh
+++ b/run-its.sh
@@ -29,7 +29,7 @@
/*) ;;
*) MAVENCODEBASE="$PWD/$MAVENCODEBASE" ;;
esac
- mvn verify -P versionlessMavenDist -f "$MAVENCODEBASE" || exit $?
+ 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"
fi