You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sj...@apache.org on 2022/05/19 16:12:59 UTC

[maven-invoker-plugin] branch MINVOKER-288 created (now 37623d8)

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

sjaranowski pushed a change to branch MINVOKER-288
in repository https://gitbox.apache.org/repos/asf/maven-invoker-plugin.git


      at 37623d8  [MINVOKER-288] Failed setup job cause skip rest of jobs

This branch includes the following new commits:

     new 37623d8  [MINVOKER-288] Failed setup job cause skip rest of jobs

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[maven-invoker-plugin] 01/01: [MINVOKER-288] Failed setup job cause skip rest of jobs

Posted by sj...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sjaranowski pushed a commit to branch MINVOKER-288
in repository https://gitbox.apache.org/repos/asf/maven-invoker-plugin.git

commit 37623d842bad1b278a0211da73a3465ee968a45d
Author: Slawomir Jaranowski <s....@gmail.com>
AuthorDate: Thu May 19 18:12:26 2022 +0200

    [MINVOKER-288] Failed setup job cause skip rest of jobs
---
 .../invoker.properties                             | 18 ++++++
 src/it/MINVOKER-288-failed-setup-run/pom.xml       | 68 +++++++++++++++++++++
 .../src/it/project1/pom.xml                        | 34 +++++++++++
 .../src/it/project2/pom.xml                        | 32 ++++++++++
 src/it/MINVOKER-288-failed-setup-run/verify.groovy | 40 +++++++++++++
 .../invoker.properties                             | 18 ++++++
 src/it/MINVOKER-288-failed-setup-verify/pom.xml    | 69 ++++++++++++++++++++++
 .../src/it/project1/pom.xml                        | 34 +++++++++++
 .../src/it/project2/pom.xml                        | 32 ++++++++++
 .../MINVOKER-288-failed-setup-verify/verify.groovy | 40 +++++++++++++
 .../maven/plugins/invoker/AbstractInvokerMojo.java | 27 ++++++---
 src/main/mdo/invocation.mdo                        |  5 ++
 12 files changed, 409 insertions(+), 8 deletions(-)

diff --git a/src/it/MINVOKER-288-failed-setup-run/invoker.properties b/src/it/MINVOKER-288-failed-setup-run/invoker.properties
new file mode 100644
index 0000000..e64d99e
--- /dev/null
+++ b/src/it/MINVOKER-288-failed-setup-run/invoker.properties
@@ -0,0 +1,18 @@
+# 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.
+
+invoker.buildResult = failure
diff --git a/src/it/MINVOKER-288-failed-setup-run/pom.xml b/src/it/MINVOKER-288-failed-setup-run/pom.xml
new file mode 100644
index 0000000..af7aec2
--- /dev/null
+++ b/src/it/MINVOKER-288-failed-setup-run/pom.xml
@@ -0,0 +1,68 @@
+<?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.plugins.invoker</groupId>
+  <artifactId>project-setup</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <packaging>pom</packaging>
+
+  <description>Test to check that failed setup projects stop executing other projects.</description>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-invoker-plugin</artifactId>
+        <version>@pom.version@</version>
+        <configuration>
+          <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
+          <writeJunitReport>true</writeJunitReport>
+          <setupIncludes>
+            <setupInclude>project1</setupInclude>
+          </setupIncludes>
+          <pomIncludes>
+            <pomInclude>*/pom.xml</pomInclude>
+          </pomIncludes>
+          <goals>
+            <goal>validate</goal>
+          </goals>
+        </configuration>
+        <executions>
+          <execution>
+            <id>integration-test</id>
+            <phase>initialize</phase>
+            <goals>
+              <goal>run</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>
diff --git a/src/it/MINVOKER-288-failed-setup-run/src/it/project1/pom.xml b/src/it/MINVOKER-288-failed-setup-run/src/it/project1/pom.xml
new file mode 100644
index 0000000..678a534
--- /dev/null
+++ b/src/it/MINVOKER-288-failed-setup-run/src/it/project1/pom.xml
@@ -0,0 +1,34 @@
+<?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>test</groupId>
+  <artifactId>project1</artifactId>
+  <version>0.1-SNAPSHOT</version>
+  <packaging>pom</packaging>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <invalidTag/>
+</project>
diff --git a/src/it/MINVOKER-288-failed-setup-run/src/it/project2/pom.xml b/src/it/MINVOKER-288-failed-setup-run/src/it/project2/pom.xml
new file mode 100644
index 0000000..a747a1e
--- /dev/null
+++ b/src/it/MINVOKER-288-failed-setup-run/src/it/project2/pom.xml
@@ -0,0 +1,32 @@
+<?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>test</groupId>
+  <artifactId>project2</artifactId>
+  <version>0.1-SNAPSHOT</version>
+  <packaging>pom</packaging>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+</project>
diff --git a/src/it/MINVOKER-288-failed-setup-run/verify.groovy b/src/it/MINVOKER-288-failed-setup-run/verify.groovy
new file mode 100644
index 0000000..92bed15
--- /dev/null
+++ b/src/it/MINVOKER-288-failed-setup-run/verify.groovy
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+
+
+File invokerReports = new File( new File(basedir, 'target'), 'invoker-reports' )
+assert invokerReports.exists()
+
+def build1 = new XmlSlurper().parse( new File( invokerReports, 'BUILD-project1.xml' ) )
+
+assert build1.@result.text() == 'failure-build'
+assert build1.@type.text() == 'setup'
+
+def build2 = new XmlSlurper().parse( new File( invokerReports, 'BUILD-project2.xml' ) )
+
+assert build2.@result.text() == 'skipped'
+assert build2.failureMessage.text() == 'Skipped due to setup job(s) failure'
+
+def testsuite = new XmlSlurper().parse( new File( invokerReports, 'TEST-project2.xml' ) )
+
+assert testsuite.@skipped.text() == '1'
+assert testsuite.testcase.skipped.text() == 'Skipped due to setup job(s) failure'
+
+def buildLog = new File( basedir, 'build.log' ).text
+assert buildLog.contains('[INFO]   Passed: 0, Failed: 1, Errors: 0, Skipped: 1')
diff --git a/src/it/MINVOKER-288-failed-setup-verify/invoker.properties b/src/it/MINVOKER-288-failed-setup-verify/invoker.properties
new file mode 100644
index 0000000..e64d99e
--- /dev/null
+++ b/src/it/MINVOKER-288-failed-setup-verify/invoker.properties
@@ -0,0 +1,18 @@
+# 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.
+
+invoker.buildResult = failure
diff --git a/src/it/MINVOKER-288-failed-setup-verify/pom.xml b/src/it/MINVOKER-288-failed-setup-verify/pom.xml
new file mode 100644
index 0000000..b1822dd
--- /dev/null
+++ b/src/it/MINVOKER-288-failed-setup-verify/pom.xml
@@ -0,0 +1,69 @@
+<?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.plugins.invoker</groupId>
+  <artifactId>project-setup</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <packaging>pom</packaging>
+
+  <description>Test to check that failed setup projects stop executing other projects.</description>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-invoker-plugin</artifactId>
+        <version>@pom.version@</version>
+        <configuration>
+          <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
+          <writeJunitReport>true</writeJunitReport>
+          <setupIncludes>
+            <setupInclude>project1</setupInclude>
+          </setupIncludes>
+          <pomIncludes>
+            <pomInclude>*/pom.xml</pomInclude>
+          </pomIncludes>
+          <goals>
+            <goal>validate</goal>
+          </goals>
+        </configuration>
+        <executions>
+          <execution>
+            <id>integration-test</id>
+            <phase>initialize</phase>
+            <goals>
+              <goal>integration-test</goal>
+              <goal>verify</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>
diff --git a/src/it/MINVOKER-288-failed-setup-verify/src/it/project1/pom.xml b/src/it/MINVOKER-288-failed-setup-verify/src/it/project1/pom.xml
new file mode 100644
index 0000000..678a534
--- /dev/null
+++ b/src/it/MINVOKER-288-failed-setup-verify/src/it/project1/pom.xml
@@ -0,0 +1,34 @@
+<?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>test</groupId>
+  <artifactId>project1</artifactId>
+  <version>0.1-SNAPSHOT</version>
+  <packaging>pom</packaging>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <invalidTag/>
+</project>
diff --git a/src/it/MINVOKER-288-failed-setup-verify/src/it/project2/pom.xml b/src/it/MINVOKER-288-failed-setup-verify/src/it/project2/pom.xml
new file mode 100644
index 0000000..a747a1e
--- /dev/null
+++ b/src/it/MINVOKER-288-failed-setup-verify/src/it/project2/pom.xml
@@ -0,0 +1,32 @@
+<?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>test</groupId>
+  <artifactId>project2</artifactId>
+  <version>0.1-SNAPSHOT</version>
+  <packaging>pom</packaging>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+</project>
diff --git a/src/it/MINVOKER-288-failed-setup-verify/verify.groovy b/src/it/MINVOKER-288-failed-setup-verify/verify.groovy
new file mode 100644
index 0000000..450fd57
--- /dev/null
+++ b/src/it/MINVOKER-288-failed-setup-verify/verify.groovy
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+
+
+File invokerReports = new File( new File(basedir, "target"), 'invoker-reports' )
+assert invokerReports.exists()
+
+def build1 = new XmlSlurper().parse( new File( invokerReports, "BUILD-project1.xml" ) )
+
+assert build1.@result.text() == "failure-build"
+assert build1.@type.text() == "setup"
+
+def build2 = new XmlSlurper().parse( new File( invokerReports, "BUILD-project2.xml" ) )
+
+assert build2.@result.text() == "skipped"
+assert build2.failureMessage.text() == "Skipped due to setup job(s) failure"
+
+def testsuite = new XmlSlurper().parse( new File( invokerReports, "TEST-project2.xml" ) )
+
+assert testsuite.@skipped.text() == "1"
+assert testsuite.testcase.skipped.text() == "Skipped due to setup job(s) failure"
+
+def buildLog = new File( basedir, 'build.log' ).text
+assert buildLog.contains('[INFO]   Passed: 0, Failed: 1, Errors: 0, Skipped: 1')
diff --git a/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java b/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java
index 74220aa..8121424 100644
--- a/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java
+++ b/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java
@@ -826,16 +826,27 @@ public abstract class AbstractInvokerMojo
             getLog().info( "Setup done." );
         }
 
-        // Afterwards run all other jobs.
-        List<BuildJob> nonSetupBuildJobs = getNonSetupJobs( buildJobs );
-        // We will run the non setup jobs with the configured
-        // parallelThreads number.
-        runBuilds( projectsDir, nonSetupBuildJobs, getParallelThreadsCount() );
 
-        writeSummaryFile( nonSetupBuildJobs );
+        List<BuildJob> nonSetupBuildJobs = getNonSetupJobs( buildJobs );
 
-        processResults( new InvokerSession( nonSetupBuildJobs ) );
+        if ( setupBuildJobs.isEmpty() || setupBuildJobs.stream().allMatch( BuildJob::isNotError ) )
+        {
+            // We will run the non setup jobs with the configured
+            // parallelThreads number.
+            runBuilds( projectsDir, nonSetupBuildJobs, getParallelThreadsCount() );
+        }
+        else
+        {
+            for ( BuildJob buildJob : nonSetupBuildJobs )
+            {
+                buildJob.setResult( BuildJob.Result.SKIPPED );
+                buildJob.setFailureMessage( "Skipped due to setup job(s) failure" );
+                writeBuildReport( buildJob );
+            }
+        }
 
+        writeSummaryFile( buildJobs );
+        processResults( new InvokerSession( buildJobs ) );
     }
 
     private void setupActualMavenVersion() throws MojoExecutionException
@@ -957,7 +968,7 @@ public abstract class AbstractInvokerMojo
         {
             for ( BuildJob buildJob : buildJobs )
             {
-                if ( !buildJob.getResult().equals( BuildJob.Result.SUCCESS ) )
+                if ( !BuildJob.Result.SUCCESS.equals( buildJob.getResult() ) )
                 {
                     writer.append( buildJob.getResult() );
                     writer.append( " [" );
diff --git a/src/main/mdo/invocation.mdo b/src/main/mdo/invocation.mdo
index 4352c2e..6529e7c 100644
--- a/src/main/mdo/invocation.mdo
+++ b/src/main/mdo/invocation.mdo
@@ -133,6 +133,11 @@ under the License.
     {
         this.project = project;
     }
+
+    public boolean isNotError()
+    {
+        return Result.SUCCESS.equals( result ) || Result.SKIPPED.equals( result );
+    }
           ]]></code>
         </codeSegment>
         <codeSegment>