You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2020/10/14 19:21:13 UTC

[maven-invoker-plugin] branch MINVOKER-267 updated (b8b0f9d -> 76939cf)

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

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


 discard b8b0f9d  [MINVOKER-267] Update maven-script-interpreter to next release version
     add 988a66a  Upgrade maven-shared-utils from 3.2.1 to 3.3.3
     add ceaef52  Update commons-io from 2.5 to 2.6
     add fdf6249  update ASF CI url
     add 7db6b79  [MINVOKER-268] - add missing space (#25)
     add d69782f  update ASF CI url
     add 3501e6b  Bump junit from 4.13 to 4.13.1
     add beaf988  Bump maven-project-info-reports-plugin from 3.1.0 to 3.1.1
     new 76939cf  [MINVOKER-267] Update maven-script-interpreter to next release version

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (b8b0f9d)
            \
             N -- N -- N   refs/heads/MINVOKER-267 (76939cf)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

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.


Summary of changes:
 README.md                                                      |  8 ++++----
 pom.xml                                                        | 10 +++++-----
 .../org/apache/maven/plugins/invoker/AbstractInvokerMojo.java  |  2 +-
 3 files changed, 10 insertions(+), 10 deletions(-)


[maven-invoker-plugin] 01/01: [MINVOKER-267] Update maven-script-interpreter to next release version

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

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

commit 76939cf0098320ffb05cc8579037623043539e51
Author: Slawomir Jaranowski <s....@gmail.com>
AuthorDate: Fri Jul 24 21:03:28 2020 +0200

    [MINVOKER-267] Update maven-script-interpreter to next release version
---
 pom.xml                                            |  2 +-
 .../maven/plugins/invoker/AbstractInvokerMojo.java | 52 +++++++++-----------
 .../apache/maven/plugins/invoker/FileLogger.java   | 17 +++++--
 .../maven/plugins/invoker/RunFailureException.java | 55 ++++++++++++++++++++++
 4 files changed, 91 insertions(+), 35 deletions(-)

diff --git a/pom.xml b/pom.xml
index 1777c77..e3094fa 100644
--- a/pom.xml
+++ b/pom.xml
@@ -130,7 +130,7 @@ under the License.
     <dependency>
       <groupId>org.apache.maven.shared</groupId>
       <artifactId>maven-script-interpreter</artifactId>
-      <version>1.2</version>
+      <version>1.3-SNAPSHOT</version>
       <exclusions>
         <!-- there's already a direct dependency to groovy-all -->
         <exclusion>
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 ee088ad..513ce3a 100644
--- a/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java
+++ b/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java
@@ -47,8 +47,8 @@ import org.apache.maven.shared.invoker.InvocationResult;
 import org.apache.maven.shared.invoker.Invoker;
 import org.apache.maven.shared.invoker.MavenCommandLineBuilder;
 import org.apache.maven.shared.invoker.MavenInvocationException;
-import org.apache.maven.shared.scriptinterpreter.RunErrorException;
-import org.apache.maven.shared.scriptinterpreter.RunFailureException;
+import org.apache.maven.shared.scriptinterpreter.ScriptException;
+import org.apache.maven.shared.scriptinterpreter.ScriptReturnException;
 import org.apache.maven.shared.scriptinterpreter.ScriptRunner;
 import org.apache.maven.shared.utils.logging.MessageBuilder;
 import org.apache.maven.toolchain.MisconfiguredToolchainException;
@@ -910,7 +910,7 @@ public abstract class AbstractInvokerMojo
         {
             scriptClassPath = null;
         }
-        scriptRunner = new ScriptRunner( getLog() );
+        scriptRunner = new ScriptRunner( );
         scriptRunner.setScriptEncoding( encoding );
         scriptRunner.setGlobalVariable( "localRepositoryPath", localRepositoryPath );
         if ( scriptVariables != null )
@@ -1817,17 +1817,6 @@ public abstract class AbstractInvokerMojo
                 buildJob.setFailureMessage( "Skipped due to " + message.toString() );
             }
         }
-        catch ( RunErrorException e )
-        {
-            buildJob.setResult( BuildJob.Result.ERROR );
-            buildJob.setFailureMessage( e.getMessage() );
-
-            if ( !suppressSummaries )
-            {
-                getLog().info( "  " + e.getMessage() );
-                getLog().info( pad( buildJob ).failure( "ERROR" ).a( ' ' ) + formatTime( buildJob.getTime() ) );
-            }
-        }
         catch ( RunFailureException e )
         {
             buildJob.setResult( e.getType() );
@@ -2038,7 +2027,7 @@ public abstract class AbstractInvokerMojo
      * @return <code>true</code> if the project was launched or <code>false</code> if the selector script indicated that
      *         the project should be skipped.
      * @throws org.apache.maven.plugin.MojoExecutionException If the project could not be launched.
-     * @throws org.apache.maven.shared.scriptinterpreter.RunFailureException If either a hook script or the build itself
+     * @throws RunFailureException If either a hook script or the build itself
      *             failed.
      */
     private boolean runBuild( File basedir, File pomFile, File settingsFile, File actualJavaHome,
@@ -2068,22 +2057,26 @@ public abstract class AbstractInvokerMojo
         {
             try
             {
-                scriptRunner.run( "selector script", basedir, selectorScript, context, logger, BuildJob.Result.SKIPPED,
-                                  false );
+                scriptRunner.run( "selector script", basedir, selectorScript, context, logger );
             }
-            catch ( RunErrorException e )
+            catch ( ScriptReturnException e )
             {
                 selectorResult = false;
-                throw e;
+                return false;
             }
-            catch ( RunFailureException e )
+            catch ( ScriptException e )
             {
-                selectorResult = false;
-                return false;
+                throw new RunFailureException( BuildJob.Result.ERROR, e );
             }
 
-            scriptRunner.run( "pre-build script", basedir, preBuildHookScript, context, logger,
-                              BuildJob.Result.FAILURE_PRE_HOOK, false );
+            try
+            {
+                scriptRunner.run( "pre-build script", basedir, preBuildHookScript, context, logger );
+            }
+            catch ( ScriptException e )
+            {
+                throw new RunFailureException( BuildJob.Result.FAILURE_PRE_HOOK, e );
+            }
 
             final InvocationRequest request = new DefaultInvocationRequest();
 
@@ -2225,15 +2218,18 @@ public abstract class AbstractInvokerMojo
     {
         try
         {
-            scriptRunner.run( "post-build script", basedir, postBuildHookScript, context, logger,
-                              BuildJob.Result.FAILURE_POST_HOOK, true );
+            scriptRunner.run( "post-build script", basedir, postBuildHookScript, context, logger );
         }
         catch ( IOException e )
         {
             throw new MojoExecutionException( e.getMessage(), e );
         }
+        catch ( ScriptException e )
+        {
+            throw new RunFailureException( e.getMessage(), BuildJob.Result.FAILURE_POST_HOOK, e );
+        }
     }
-    private void setupLoggerForBuildJob( FileLogger logger, final InvocationRequest request )
+    private void setupLoggerForBuildJob( final FileLogger logger, final InvocationRequest request )
     {
         if ( logger != null )
         {
@@ -2357,8 +2353,6 @@ public abstract class AbstractInvokerMojo
      * @param invocationIndex The index of the invocation for which to check the exit code, must not be negative.
      * @param invokerProperties The invoker properties used to check the exit code, must not be <code>null</code>.
      * @param logger The build logger, may be <code>null</code> if logging is disabled.
-     * @throws org.apache.maven.shared.scriptinterpreter.RunFailureException If the invocation result indicates a build
-     *             failure.
      */
     private void verify( InvocationResult result, int invocationIndex, InvokerProperties invokerProperties,
                          FileLogger logger )
diff --git a/src/main/java/org/apache/maven/plugins/invoker/FileLogger.java b/src/main/java/org/apache/maven/plugins/invoker/FileLogger.java
index 9e67115..dfe009b 100644
--- a/src/main/java/org/apache/maven/plugins/invoker/FileLogger.java
+++ b/src/main/java/org/apache/maven/plugins/invoker/FileLogger.java
@@ -24,14 +24,14 @@ import java.io.IOException;
 
 import org.apache.maven.plugin.logging.Log;
 import org.apache.maven.shared.invoker.InvocationOutputHandler;
-import org.apache.maven.shared.scriptinterpreter.ExecutionLogger;
+import org.apache.maven.shared.scriptinterpreter.FileLoggerMirrorHandler;
 
 /**
  *
  */
 class FileLogger
     extends org.apache.maven.shared.scriptinterpreter.FileLogger
-    implements InvocationOutputHandler, ExecutionLogger
+    implements InvocationOutputHandler
 {
 
     /**
@@ -43,7 +43,7 @@ class FileLogger
     FileLogger( File outputFile )
         throws IOException
     {
-        super( outputFile, null );
+        super( outputFile );
     }
 
     /**
@@ -53,10 +53,17 @@ class FileLogger
      * @param log The mojo logger to additionally output messages to, may be <code>null</code> if not used.
      * @throws IOException If the output file could not be created.
      */
-    FileLogger( File outputFile, Log log )
+    FileLogger( File outputFile, final Log log )
         throws IOException
     {
-        super( outputFile, log );
+        super( outputFile, new FileLoggerMirrorHandler()
+        {
+            @Override
+            public void consumeOutput( String message )
+            {
+                log.info( message );
+            }
+        } );
     }
 
 }
diff --git a/src/main/java/org/apache/maven/plugins/invoker/RunFailureException.java b/src/main/java/org/apache/maven/plugins/invoker/RunFailureException.java
new file mode 100644
index 0000000..1966fc6
--- /dev/null
+++ b/src/main/java/org/apache/maven/plugins/invoker/RunFailureException.java
@@ -0,0 +1,55 @@
+package org.apache.maven.plugins.invoker;
+
+/*
+ * 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.
+ */
+
+/**
+ * Provide an error during test invocation.
+ *
+ * @author Slawomir Jaranowski
+ */
+public class RunFailureException extends Exception
+{
+
+    private final String type;
+
+    public RunFailureException( String message, String type )
+    {
+        super( message );
+        this.type = type;
+    }
+
+    public RunFailureException( String type, Throwable cause )
+    {
+        super( cause );
+        this.type = type;
+
+    }
+
+    public RunFailureException( String message, String type, Throwable cause )
+    {
+        super( message, cause );
+        this.type = type;
+    }
+
+    public String getType()
+    {
+        return type;
+    }
+}