Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class ResourceScriptEvaluator extends AbstractScriptEvaluator {
private final String engineName;

/**
* @param engineName optional engine name, used to override the engine selection from the file extension
* @param engineName optional engine name, used to override the engine selection from the file extension
* @param resourceName not null
*/
public ResourceScriptEvaluator(String engineName, String resourceName) {
Expand All @@ -58,17 +58,23 @@ public ResourceScriptEvaluator(String engineName, String resourceName) {
}

/**
* @param engine the script engine
* @param engine the script engine
* @param context the script context
* @return the result of the scriptFile
* @throws ScriptException if an error occurs in script
* @see org.apache.maven.plugins.scripting.AbstractScriptEvaluator#eval(javax.script.ScriptEngine, javax.script.ScriptContext)
*/
protected Object eval(ScriptEngine engine, ScriptContext context) throws ScriptException {

try (InputStream is = this.getClass().getClassLoader().getResourceAsStream(resourceName);
Reader reader = new InputStreamReader(is)) {
return engine.eval(reader, context);
try (InputStream is = this.getClass().getClassLoader().getResourceAsStream(resourceName)) {

if (is == null) {
throw new ScriptException("Resource not found: " + resourceName);
}

try (Reader reader = new InputStreamReader(is)) {
return engine.eval(reader, context);
}
} catch (IOException ex) {
throw new UncheckedIOException(resourceName + " caused:", ex);
}
Expand Down