Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump maven-shared-components from 37 to 38 #83

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version='1.0' encoding='UTF-8'?>
<?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
Expand All @@ -22,8 +22,8 @@
<parent>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-shared-components</artifactId>
<version>37</version>
<relativePath />
<version>38</version>
<relativePath/>
</parent>

<artifactId>maven-script-interpreter</artifactId>
Expand All @@ -35,30 +35,27 @@
<scm>
<connection>scm:git:https://gitbox.apache.org/repos/asf/maven-script-interpreter.git</connection>
<developerConnection>scm:git:https://gitbox.apache.org/repos/asf/maven-script-interpreter.git</developerConnection>
<url>https://github.com/apache/maven-script-interpreter/tree/${project.scm.tag}</url>
<tag>HEAD</tag>
<url>https://github.com/apache/maven-script-interpreter/tree/${project.scm.tag}</url>
</scm>
<issueManagement>
<system>jira</system>
<url>https://issues.apache.org/jira/browse/MSHARED</url>
</issueManagement>
<ciManagement>
<system>Jenkins</system>
<url>https://ci-builds.apache.org/job/Maven/job/maven-box/job/maven-script-interpreter/</url>
<url>https://ci-maven.apache.org/job/Maven/job/maven-box/job/maven-script-interpreter/</url>
</ciManagement>
<distributionManagement>
<site>
<id>apache.website</id>
<url>scm:svn:https://svn.apache.org/repos/asf/maven/website/components/${maven.site.path}</url>
</site>
</distributionManagement>

<properties>
<javaVersion>8</javaVersion>
<project.build.outputTimestamp>2020-10-15T00:00:05Z</project.build.outputTimestamp>
<slf4j.version>1.7.36</slf4j.version>
<surefire.version>3.0.0-M6</surefire.version>
<checkstyle.violation.ignore>None</checkstyle.violation.ignore>
</properties>

<dependencyManagement>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
* 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.
*/
package org.apache.maven.shared.scriptinterpreter;

/*
Expand All @@ -23,7 +41,6 @@
import bsh.EvalError;
import bsh.Interpreter;
import bsh.TargetError;

import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
Expand All @@ -35,98 +52,72 @@
*
* @author Benjamin Bentmann
*/
class BeanShellScriptInterpreter
implements ScriptInterpreter
{
class BeanShellScriptInterpreter implements ScriptInterpreter {

/** {@inheritDoc} */
@Override
public Object evaluateScript( String script, List<String> classPath, Map<String, ? extends Object> globalVariables,
PrintStream scriptOutput )
throws ScriptEvaluationException
{
public Object evaluateScript(
String script,
List<String> classPath,
Map<String, ? extends Object> globalVariables,
PrintStream scriptOutput)
throws ScriptEvaluationException {
PrintStream origOut = System.out;
PrintStream origErr = System.err;

try
{
try {
Interpreter engine = new Interpreter();

if ( scriptOutput != null )
{
System.setErr( scriptOutput );
System.setOut( scriptOutput );
engine.setErr( scriptOutput );
engine.setOut( scriptOutput );
if (scriptOutput != null) {
System.setErr(scriptOutput);
System.setOut(scriptOutput);
engine.setErr(scriptOutput);
engine.setOut(scriptOutput);
}

if ( !Capabilities.haveAccessibility() )
{
try
{
Capabilities.setAccessibility( true );
}
catch ( Exception e )
{
if ( scriptOutput != null )
{
e.printStackTrace( scriptOutput );
if (!Capabilities.haveAccessibility()) {
try {
Capabilities.setAccessibility(true);
} catch (Exception e) {
if (scriptOutput != null) {
e.printStackTrace(scriptOutput);
}
}
}

if ( classPath != null && !classPath.isEmpty() )
{
for ( String path : classPath )
{
try
{
engine.getClassManager().addClassPath( new File( path ).toURI().toURL() );
}
catch ( IOException e )
{
throw new RuntimeException( "bad class path: " + path, e );
if (classPath != null && !classPath.isEmpty()) {
for (String path : classPath) {
try {
engine.getClassManager()
.addClassPath(new File(path).toURI().toURL());
} catch (IOException e) {
throw new RuntimeException("bad class path: " + path, e);
}
}
}

if ( globalVariables != null )
{
for ( Map.Entry<String, ?> entry : globalVariables.entrySet() )
{
try
{
engine.set( entry.getKey(), entry.getValue() );
}
catch ( EvalError e )
{
throw new RuntimeException( e );
if (globalVariables != null) {
for (Map.Entry<String, ?> entry : globalVariables.entrySet()) {
try {
engine.set(entry.getKey(), entry.getValue());
} catch (EvalError e) {
throw new RuntimeException(e);
}
}
}

try
{
return engine.eval( script );
}
catch ( TargetError e )
{
throw new ScriptEvaluationException( e.getTarget() );
}
catch ( ThreadDeath e )
{
try {
return engine.eval(script);
} catch (TargetError e) {
throw new ScriptEvaluationException(e.getTarget());
} catch (ThreadDeath e) {
throw e;
} catch (Throwable e) {
throw new ScriptEvaluationException(e);
}
catch ( Throwable e )
{
throw new ScriptEvaluationException( e );
}
}
finally
{
System.setErr( origErr );
System.setOut( origOut );
} finally {
System.setErr(origErr);
System.setOut(origOut);
}
}

}
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
* 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.
*/
package org.apache.maven.shared.scriptinterpreter;

/*
Expand Down Expand Up @@ -26,8 +44,7 @@
*
* @author Olivier Lamy
*/
public interface ExecutionLogger
{
public interface ExecutionLogger {
/**
* The stream which will catch the output of the {@link org.apache.maven.shared.scriptinterpreter.ScriptRunner}.
*
Expand All @@ -40,5 +57,5 @@ public interface ExecutionLogger
*
* @param line the line to consume
*/
void consumeLine( String line );
void consumeLine(String line);
}
Loading