You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mt...@apache.org on 2021/03/22 14:09:36 UTC

[maven-integration-testing] branch master updated: [MNG-6511] Testing whether projects can be marked optional during (de)selection using --projects.

This is an automated email from the ASF dual-hosted git repository.

mthmulders pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-integration-testing.git


The following commit(s) were added to refs/heads/master by this push:
     new 9be9c24  [MNG-6511] Testing whether projects can be marked optional during (de)selection using --projects.
9be9c24 is described below

commit 9be9c24999bfca177efdc5881b149a487ef5d6fc
Author: Martin Kanters <ma...@apache.org>
AuthorDate: Fri Jan 8 17:31:02 2021 +0100

    [MNG-6511] Testing whether projects can be marked optional during (de)selection using --projects.
    
    Closes #100.
---
 .../org/apache/maven/it/IntegrationTestSuite.java  |   1 +
 ...MavenITmng6511OptionalProjectSelectionTest.java | 104 +++++++++++++++++++++
 .../.mvn/.gitkeep                                  |   0
 .../existing-module/pom.xml                        |  56 +++++++++++
 .../src/main/java/org/apache/its/mng6511/App.java  |  28 ++++++
 .../mng-6511-optional-project-selection/pom.xml    |  65 +++++++++++++
 6 files changed, 254 insertions(+)

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 25b9375..d9be087 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 @@ public class IntegrationTestSuite
         // Tests that don't run stable and need to be fixed
         // -------------------------------------------------------------------------------------------------------------
         // suite.addTestSuite( MavenIT0108SnapshotUpdateTest.class ); -- MNG-3137
+        suite.addTestSuite( MavenITmng6511OptionalProjectSelectionTest.class );
         suite.addTestSuite( MavenITmng7110ExtensionClassloader.class );
         suite.addTestSuite( MavenITmng7051OptionalProfileActivationTest.class );
         suite.addTestSuite( MavenITmng6957BuildConsumer.class );
diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6511OptionalProjectSelectionTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6511OptionalProjectSelectionTest.java
new file mode 100644
index 0000000..6139589
--- /dev/null
+++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6511OptionalProjectSelectionTest.java
@@ -0,0 +1,104 @@
+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;
+
+/**
+ * This is a collection of test cases for <a href="https://issues.apache.org/jira/browse/MNG-6511">MNG-6511</a>,
+ * selecting and deselecting optional projects.
+ *
+ * @author Maarten Mulders
+ * @author Martin Kanters
+ */
+public class MavenITmng6511OptionalProjectSelectionTest extends AbstractMavenIntegrationTestCase
+{
+    private static final String RESOURCE_PATH = "/mng-6511-optional-project-selection";
+    private final File testDir;
+
+    public MavenITmng6511OptionalProjectSelectionTest() throws IOException
+    {
+        super( "[4.0.0-alpha-1,)" );
+        testDir = ResourceExtractor.simpleExtractResources( getClass(), RESOURCE_PATH );
+    }
+
+    public void testSelectExistingOptionalProfile() throws VerificationException
+    {
+        newVerifier( testDir.getAbsolutePath() ).executeGoal( "clean" );
+
+        Verifier verifier = newVerifier( testDir.getAbsolutePath() );
+        verifier.setLogFileName( "log-select-existing.txt" );
+        verifier.addCliOption( "-pl ?existing-module" );
+        verifier.executeGoal( "validate" );
+        verifier.verifyErrorFreeLog();
+        verifier.assertFilePresent( "existing-module/target/touch.txt" ); // existing-module should have been built.
+    }
+
+    public void testSelectExistingOptionalProfileByArtifactId() throws VerificationException
+    {
+        newVerifier( testDir.getAbsolutePath() ).executeGoal( "clean" );
+
+        Verifier verifier = newVerifier( testDir.getAbsolutePath() );
+        verifier.setLogFileName( "log-select-existing-artifact-id.txt" );
+        verifier.addCliOption( "-pl ?:existing-module" );
+        verifier.executeGoal( "validate" );
+        verifier.verifyErrorFreeLog();
+        verifier.assertFilePresent( "existing-module/target/touch.txt" ); // existing-module should have been built.
+    }
+
+    public void testSelectNonExistingOptionalProfile() throws VerificationException
+    {
+        newVerifier( testDir.getAbsolutePath() ).executeGoal( "clean" );
+
+        Verifier verifier = newVerifier( testDir.getAbsolutePath() );
+        verifier.setLogFileName( "log-select-non-existing.txt" );
+        verifier.addCliOption( "-pl ?non-existing-module" );
+        verifier.executeGoal( "validate" );
+        verifier.verifyErrorFreeLog();
+        verifier.assertFilePresent( "existing-module/target/touch.txt" ); // existing-module should have been built.
+    }
+
+    public void testDeselectExistingOptionalProfile() throws VerificationException
+    {
+        newVerifier( testDir.getAbsolutePath() ).executeGoal( "clean" );
+
+        Verifier verifier = newVerifier( testDir.getAbsolutePath() );
+        verifier.setLogFileName( "log-deselect-existing.txt" );
+        verifier.addCliOption( "-pl !?existing-module" );
+        verifier.executeGoal( "validate" );
+        verifier.verifyErrorFreeLog();
+        verifier.assertFileNotPresent( "existing-module/target/touch.txt" ); // existing-module should not have been built.
+    }
+
+    public void testDeselectNonExistingOptionalProfile() throws VerificationException
+    {
+        newVerifier( testDir.getAbsolutePath() ).executeGoal( "clean" );
+
+        Verifier verifier = newVerifier( testDir.getAbsolutePath() );
+        verifier.setLogFileName( "log-deselect-non-existing.txt" );
+        verifier.addCliOption( "-pl !?non-existing-module" );
+        verifier.executeGoal( "validate" );
+        verifier.verifyErrorFreeLog();
+        verifier.assertFilePresent( "existing-module/target/touch.txt" ); // existing-module should have been built.
+    }
+}
diff --git a/core-it-suite/src/test/resources/mng-6511-optional-project-selection/.mvn/.gitkeep b/core-it-suite/src/test/resources/mng-6511-optional-project-selection/.mvn/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/core-it-suite/src/test/resources/mng-6511-optional-project-selection/existing-module/pom.xml b/core-it-suite/src/test/resources/mng-6511-optional-project-selection/existing-module/pom.xml
new file mode 100644
index 0000000..15902f9
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-6511-optional-project-selection/existing-module/pom.xml
@@ -0,0 +1,56 @@
+<?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/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <artifactId>parent</artifactId>
+    <groupId>org.apache.its.mng6511</groupId>
+    <version>1.0</version>
+  </parent>
+
+  <artifactId>existing-module</artifactId>
+  <name>Maven Integration Test :: MNG-6511 :: Existing Module</name>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.its.plugins</groupId>
+        <artifactId>maven-it-plugin-log-file</artifactId>
+        <version>2.1-SNAPSHOT</version>
+        <configuration>
+          <logFile>target/touch.txt</logFile>
+        </configuration>
+        <executions>
+          <execution>
+            <id>test</id>
+            <phase>validate</phase>
+            <goals>
+              <goal>reset</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/core-it-suite/src/test/resources/mng-6511-optional-project-selection/existing-module/src/main/java/org/apache/its/mng6511/App.java b/core-it-suite/src/test/resources/mng-6511-optional-project-selection/existing-module/src/main/java/org/apache/its/mng6511/App.java
new file mode 100644
index 0000000..bf99580
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-6511-optional-project-selection/existing-module/src/main/java/org/apache/its/mng6511/App.java
@@ -0,0 +1,28 @@
+package org.apache.its.mng6511;
+
+/*
+ * 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.
+ */
+
+public class App
+{
+    public static void main( String[] args )
+    {
+        System.out.println( "Hello World!" );
+    }
+}
diff --git a/core-it-suite/src/test/resources/mng-6511-optional-project-selection/pom.xml b/core-it-suite/src/test/resources/mng-6511-optional-project-selection/pom.xml
new file mode 100644
index 0000000..804ee11
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-6511-optional-project-selection/pom.xml
@@ -0,0 +1,65 @@
+<?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/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.its.mng6511</groupId>
+  <artifactId>parent</artifactId>
+  <version>1.0</version>
+
+  <packaging>pom</packaging>
+
+  <name>Maven Integration Test :: MNG-6511</name>
+  <description>
+    Tests for selecting and deselecting optional projects using the question mark classifier.
+  </description>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <maven.compiler.source>1.8</maven.compiler.source>
+    <maven.compiler.target>1.8</maven.compiler.target>
+  </properties>
+
+  <modules>
+    <module>existing-module</module>
+  </modules>
+
+  <build>
+    <pluginManagement>
+      <!-- maven-resources-plugin, maven-compiler-plugin -->
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-resources-plugin</artifactId>
+          <version>2.7</version>
+        </plugin>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-compiler-plugin</artifactId>
+          <version>2.0.2</version>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
+</project>