[MINVOKER-267] Update maven-script-interpreter to 1.3
diff --git a/pom.xml b/pom.xml
index 1777c77..98bdf1f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -130,7 +130,7 @@
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-script-interpreter</artifactId>
- <version>1.2</version>
+ <version>1.3</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 cf1d7e5..cb4f853 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.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;
@@ -912,7 +912,7 @@
{
scriptClassPath = null;
}
- scriptRunner = new ScriptRunner( getLog() );
+ scriptRunner = new ScriptRunner( );
scriptRunner.setScriptEncoding( encoding );
scriptRunner.setGlobalVariable( "localRepositoryPath", localRepositoryPath );
if ( scriptVariables != null )
@@ -1819,17 +1819,6 @@
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() );
@@ -2040,7 +2029,7 @@
* @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,
@@ -2070,22 +2059,26 @@
{
try
{
- scriptRunner.run( "selector script", basedir, selectorScript, context, logger, BuildJob.Result.SKIPPED,
- false );
+ scriptRunner.run( "selector script", basedir, selectorScript, context, logger );
}
- catch ( RunErrorException e )
- {
- selectorResult = false;
- throw e;
- }
- catch ( RunFailureException e )
+ catch ( ScriptReturnException e )
{
selectorResult = false;
return false;
}
+ catch ( ScriptException e )
+ {
+ 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();
@@ -2227,15 +2220,18 @@
{
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 )
{
@@ -2359,8 +2355,6 @@
* @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 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 @@
FileLogger( File outputFile )
throws IOException
{
- super( outputFile, null );
+ super( outputFile );
}
/**
@@ -53,10 +53,17 @@
* @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;
+ }
+}