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

kwin pushed a commit to branch feature/java-prerequisites-in-plugin-descriptor
in repository https://gitbox.apache.org/repos/asf/maven-integration-testing.git

commit 0bdbe2cfc2d0e41af776696198761e80194b4724
Author: Konrad Windszus <[email protected]>
AuthorDate: Fri Oct 14 12:37:44 2022 +0200

    [MNG-7566] Support Java prerequisites in plugin descriptor
---
 .../org/apache/maven/it/IntegrationTestSuite.java  |   1 +
 .../it/MavenITmng7566JavaPrerequisiteTest.java     |  99 +++++++++++++++++++++
 .../test/resources/mng-7566/repo/.gitattributes    |   3 +
 .../0.1/maven-mng7566-plugin-0.1.jar               | Bin 0 -> 14658 bytes
 .../0.1/maven-mng7566-plugin-0.1.pom               |  65 ++++++++++++++
 .../0.2/maven-mng7566-plugin-0.2.jar               | Bin 0 -> 13205 bytes
 .../0.2/maven-mng7566-plugin-0.2.pom               |  65 ++++++++++++++
 .../maven-mng7566-plugin/maven-metadata.xml        |  14 +++
 .../test/resources/mng-7566/settings-template.xml  |  55 ++++++++++++
 .../src/test/resources/mng-7566/test-1/pom.xml     |  54 +++++++++++
 .../src/test/resources/mng-7566/test-2/pom.xml     |  35 ++++++++
 11 files changed, 391 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 a0fcf09a0..adb498ba8 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
@@ -105,6 +105,7 @@ public class IntegrationTestSuite
         // Tests that don't run stable and need to be fixed
         // 
-------------------------------------------------------------------------------------------------------------
         // suite.addTestSuite( MavenIT0108SnapshotUpdateTest.class ); -- 
MNG-3137
+        suite.addTestSuite( MavenITmng7566JavaPrerequisiteTest.class );
         suite.addTestSuite( MavenITmng7474SessionScopeTest.class );
         suite.addTestSuite( 
MavenITmng7529VersionRangeRepositorySelection.class );
         suite.addTestSuite( 
MavenITmng7443ConsistencyOfOptionalProjectsAndProfilesTest.class );
diff --git 
a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng7566JavaPrerequisiteTest.java
 
b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng7566JavaPrerequisiteTest.java
new file mode 100644
index 000000000..c01777ce2
--- /dev/null
+++ 
b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng7566JavaPrerequisiteTest.java
@@ -0,0 +1,99 @@
+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;
+
+/**
+ * This is a test set for <a 
href="https://issues.apache.org/jira/browse/MNG-7566";>MNG-7566</a>.
+ * Similar to {@link MavenITmng4840MavenPrerequisiteTest}.
+ *
+ */
+public class MavenITmng7566JavaPrerequisiteTest
+    extends AbstractMavenIntegrationTestCase
+{
+
+    public MavenITmng7566JavaPrerequisiteTest()
+    {
+        super( "[4.0.0-alpha-1,)" );
+    }
+
+    /**
+     * Verify that builds fail straight when the current Java version doesn't 
match a plugin's prerequisite.
+     *
+     * @throws Exception in case of failure
+     */
+    public void testitMojoExecution()
+        throws Exception
+    {
+        File testDir = ResourceExtractor.simpleExtractResources( getClass(), 
"/mng-7566" );
+
+        Verifier verifier = newVerifier( new File( testDir, "test-1" 
).getAbsolutePath() );
+        verifier.setAutoclean( false );
+        verifier.deleteDirectory( "target" );
+        verifier.deleteArtifacts( "org.apache.maven.its.mng7566" );
+        verifier.addCliOption( "-s" );
+        verifier.addCliOption( "settings.xml" );
+        verifier.filterFile( "../settings-template.xml", "settings.xml", 
"UTF-8", verifier.newDefaultFilterProperties() );
+        try
+        {
+            verifier.executeGoal( "validate" );
+            verifier.verifyErrorFreeLog();
+            fail( "Build did not fail despite unsatisfied prerequisite of 
plugin on Maven version." );
+        }
+        catch ( Exception e )
+        {
+            // expected, unsolvable version conflict
+        }
+        finally
+        {
+            verifier.resetStreams();
+        }
+    }
+
+    /**
+     * Verify that automatic plugin version resolution automatically skips 
plugin versions whose prerequisite on
+     * the current Java version isn't satisfied.
+     *
+     * @throws Exception in case of failure
+     */
+    public void testitPluginVersionResolution()
+        throws Exception
+    {
+        File testDir = ResourceExtractor.simpleExtractResources( getClass(), 
"/mng-7566" );
+
+        Verifier verifier = newVerifier( new File( testDir, "test-2" 
).getAbsolutePath() );
+        verifier.setAutoclean( false );
+        verifier.deleteDirectory( "target" );
+        verifier.deleteArtifacts( "org.apache.maven.its.mng7566" );
+        verifier.addCliOption( "-s" );
+        verifier.addCliOption( "settings.xml" );
+        verifier.filterFile( "../settings-template.xml", "settings.xml", 
"UTF-8", verifier.newDefaultFilterProperties() );
+        verifier.executeGoal( 
"org.apache.maven.its.mng7566:maven-mng7566-plugin:touch" );
+        verifier.verifyErrorFreeLog();
+        verifier.resetStreams();
+
+        verifier.verifyFilePresent( "target/touch-1.txt" );
+        verifier.verifyFileNotPresent( "target/touch-2.txt" );
+    }
+
+}
diff --git a/core-it-suite/src/test/resources/mng-7566/repo/.gitattributes 
b/core-it-suite/src/test/resources/mng-7566/repo/.gitattributes
new file mode 100644
index 000000000..e3bce59d1
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-7566/repo/.gitattributes
@@ -0,0 +1,3 @@
+*.pom    text eol=lf
+maven-metadata.xml    text eol=lf
+
diff --git 
a/core-it-suite/src/test/resources/mng-7566/repo/org/apache/maven/its/mng7566/maven-mng7566-plugin/0.1/maven-mng7566-plugin-0.1.jar
 
b/core-it-suite/src/test/resources/mng-7566/repo/org/apache/maven/its/mng7566/maven-mng7566-plugin/0.1/maven-mng7566-plugin-0.1.jar
new file mode 100644
index 000000000..96f56bc32
Binary files /dev/null and 
b/core-it-suite/src/test/resources/mng-7566/repo/org/apache/maven/its/mng7566/maven-mng7566-plugin/0.1/maven-mng7566-plugin-0.1.jar
 differ
diff --git 
a/core-it-suite/src/test/resources/mng-7566/repo/org/apache/maven/its/mng7566/maven-mng7566-plugin/0.1/maven-mng7566-plugin-0.1.pom
 
b/core-it-suite/src/test/resources/mng-7566/repo/org/apache/maven/its/mng7566/maven-mng7566-plugin/0.1/maven-mng7566-plugin-0.1.pom
new file mode 100644
index 000000000..bab251da2
--- /dev/null
+++ 
b/core-it-suite/src/test/resources/mng-7566/repo/org/apache/maven/its/mng7566/maven-mng7566-plugin/0.1/maven-mng7566-plugin-0.1.pom
@@ -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.maven.its.mng7566</groupId>
+  <artifactId>maven-mng7566-plugin</artifactId>
+  <version>0.1</version>
+  <packaging>maven-plugin</packaging>
+
+  <name>Maven Integration Test Plugin :: Touch</name>
+
+  <distributionManagement>
+    <repository>
+      <id>maven-core-it</id>
+      <url>file:///${basedir}/repo</url>
+    </repository>
+  </distributionManagement>
+
+  <properties>
+    <maven.test.skip>true</maven.test.skip>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-plugin-api</artifactId>
+      <version>2.0</version>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <resources>
+      <resource>
+        <directory>.</directory>
+        <includes>
+          <include>pom.xml</include>
+          <include>src/**</include>
+        </includes>
+      </resource>
+      <resource>
+        <directory>src/main/resources</directory>
+      </resource>
+    </resources>
+  </build>
+</project>
diff --git 
a/core-it-suite/src/test/resources/mng-7566/repo/org/apache/maven/its/mng7566/maven-mng7566-plugin/0.2/maven-mng7566-plugin-0.2.jar
 
b/core-it-suite/src/test/resources/mng-7566/repo/org/apache/maven/its/mng7566/maven-mng7566-plugin/0.2/maven-mng7566-plugin-0.2.jar
new file mode 100644
index 000000000..a3fd5b085
Binary files /dev/null and 
b/core-it-suite/src/test/resources/mng-7566/repo/org/apache/maven/its/mng7566/maven-mng7566-plugin/0.2/maven-mng7566-plugin-0.2.jar
 differ
diff --git 
a/core-it-suite/src/test/resources/mng-7566/repo/org/apache/maven/its/mng7566/maven-mng7566-plugin/0.2/maven-mng7566-plugin-0.2.pom
 
b/core-it-suite/src/test/resources/mng-7566/repo/org/apache/maven/its/mng7566/maven-mng7566-plugin/0.2/maven-mng7566-plugin-0.2.pom
new file mode 100644
index 000000000..c5d5a8c2b
--- /dev/null
+++ 
b/core-it-suite/src/test/resources/mng-7566/repo/org/apache/maven/its/mng7566/maven-mng7566-plugin/0.2/maven-mng7566-plugin-0.2.pom
@@ -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.maven.its.mng7566</groupId>
+  <artifactId>maven-mng7566-plugin</artifactId>
+  <version>0.2</version>
+  <packaging>maven-plugin</packaging>
+
+  <name>Maven Integration Test Plugin :: Touch</name>
+
+  <distributionManagement>
+    <repository>
+      <id>maven-core-it</id>
+      <url>file:///${basedir}/repo</url>
+    </repository>
+  </distributionManagement>
+
+  <properties>
+    <maven.test.skip>true</maven.test.skip>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-plugin-api</artifactId>
+      <version>2.0</version>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <resources>
+      <resource>
+        <directory>.</directory>
+        <includes>
+          <include>pom.xml</include>
+          <include>src/**</include>
+        </includes>
+      </resource>
+      <resource>
+        <directory>src/main/resources</directory>
+      </resource>
+    </resources>
+  </build>
+</project>
diff --git 
a/core-it-suite/src/test/resources/mng-7566/repo/org/apache/maven/its/mng7566/maven-mng7566-plugin/maven-metadata.xml
 
b/core-it-suite/src/test/resources/mng-7566/repo/org/apache/maven/its/mng7566/maven-mng7566-plugin/maven-metadata.xml
new file mode 100644
index 000000000..6447b57d9
--- /dev/null
+++ 
b/core-it-suite/src/test/resources/mng-7566/repo/org/apache/maven/its/mng7566/maven-mng7566-plugin/maven-metadata.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<metadata>
+  <groupId>org.apache.maven.its.mng4840</groupId>
+  <artifactId>maven-mng4840-plugin</artifactId>
+  <versioning>
+    <latest>0.2</latest>
+    <release>0.2</release>
+    <versions>
+      <version>0.2</version>
+      <version>0.1</version>
+    </versions>
+    <lastUpdated>20110104144317</lastUpdated>
+  </versioning>
+</metadata>
diff --git a/core-it-suite/src/test/resources/mng-7566/settings-template.xml 
b/core-it-suite/src/test/resources/mng-7566/settings-template.xml
new file mode 100644
index 000000000..3e21c0cf3
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-7566/settings-template.xml
@@ -0,0 +1,55 @@
+<?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.
+-->
+
+<settings>
+  <profiles>
+    <profile>
+      <id>maven-core-it-repo</id>
+      <repositories>
+        <repository>
+          <id>maven-core-it</id>
+          <url>@baseurl@/../repo</url>
+          <releases>
+            <checksumPolicy>ignore</checksumPolicy>
+          </releases>
+          <snapshots>
+            <enabled>false</enabled>
+          </snapshots>
+        </repository>
+      </repositories>
+      <pluginRepositories>
+        <pluginRepository>
+          <id>maven-core-it</id>
+          <url>@baseurl@/../repo</url>
+          <releases>
+            <checksumPolicy>ignore</checksumPolicy>
+          </releases>
+          <snapshots>
+            <enabled>false</enabled>
+          </snapshots>
+        </pluginRepository>
+      </pluginRepositories>
+    </profile>
+  </profiles>
+  <activeProfiles>
+    <activeProfile>maven-core-it-repo</activeProfile>
+  </activeProfiles>
+</settings>
diff --git a/core-it-suite/src/test/resources/mng-7566/test-1/pom.xml 
b/core-it-suite/src/test/resources/mng-7566/test-1/pom.xml
new file mode 100644
index 000000000..37b598e52
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-7566/test-1/pom.xml
@@ -0,0 +1,54 @@
+<?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.mng7566</groupId>
+  <artifactId>test</artifactId>
+  <version>0.1</version>
+  <packaging>jar</packaging>
+
+  <name>Maven Integration Test :: MNG-7566</name>
+  <description>
+    Verify that builds fail straight when the current Java version doesn't 
match a plugin's prerequisite.
+  </description>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.its.mng7566</groupId>
+        <artifactId>maven-mng7566-plugin</artifactId>
+        <!-- This version requires Java 100 which is not quite there yet -->
+        <version>0.2</version>
+        <executions>
+          <execution>
+            <id>test</id>
+            <phase>validate</phase>
+            <goals>
+              <goal>touch</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/core-it-suite/src/test/resources/mng-7566/test-2/pom.xml 
b/core-it-suite/src/test/resources/mng-7566/test-2/pom.xml
new file mode 100644
index 000000000..d9ca6460c
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-7566/test-2/pom.xml
@@ -0,0 +1,35 @@
+<?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.mng7566</groupId>
+  <artifactId>test</artifactId>
+  <version>0.1</version>
+  <packaging>jar</packaging>
+
+  <name>Maven Integration Test :: MNG-7566</name>
+  <description>
+    Verify that automatic plugin version resolution automatically skips plugin 
versions whose prerequisite on
+    the current Java version isn't satisfied.
+  </description>
+</project>

Reply via email to