From d85216bea0c1c3a65060ab33e4573e57a97d9b1e Mon Sep 17 00:00:00 2001 From: Avinash Niyas Date: Mon, 29 Dec 2025 02:02:31 +0530 Subject: [PATCH 1/3] Fix for resource not available in ResourceScriptEvaluator Signed-off-by: Avinash Niyas --- .../scripting/ResourceScriptEvaluator.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/scripting/ResourceScriptEvaluator.java b/src/main/java/org/apache/maven/plugins/scripting/ResourceScriptEvaluator.java index 8db4eb6..ffe5472 100644 --- a/src/main/java/org/apache/maven/plugins/scripting/ResourceScriptEvaluator.java +++ b/src/main/java/org/apache/maven/plugins/scripting/ResourceScriptEvaluator.java @@ -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) { @@ -58,7 +58,7 @@ 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 @@ -66,14 +66,19 @@ public ResourceScriptEvaluator(String engineName, String resourceName) { */ 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); } } + /** * Gets the script engine by engineName, otherwise by extension of the sciptFile. * From 34f27344820dd5b2d8dad5eafca56219725b6eab Mon Sep 17 00:00:00 2001 From: Avinash Niyas Date: Tue, 30 Dec 2025 07:08:46 +0530 Subject: [PATCH 2/3] ResourceScriptEvaluator null check Signed-off-by: Avinash Niyas --- .../maven/plugins/scripting/ResourceScriptEvaluator.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/scripting/ResourceScriptEvaluator.java b/src/main/java/org/apache/maven/plugins/scripting/ResourceScriptEvaluator.java index ffe5472..90d5ffd 100644 --- a/src/main/java/org/apache/maven/plugins/scripting/ResourceScriptEvaluator.java +++ b/src/main/java/org/apache/maven/plugins/scripting/ResourceScriptEvaluator.java @@ -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) { @@ -58,7 +58,7 @@ 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 @@ -68,7 +68,9 @@ protected Object eval(ScriptEngine engine, ScriptContext context) throws ScriptE try (InputStream is = this.getClass().getClassLoader().getResourceAsStream(resourceName)) { - if (is == null) throw new ScriptException("Resource not found : " + resourceName); + if (is == null) { + throw new ScriptException("Resource not found : " + resourceName); + } try (Reader reader = new InputStreamReader(is)) { return engine.eval(reader, context); From c6d4d9d38811ad0992e17b624e5d9bbf58bc87c5 Mon Sep 17 00:00:00 2001 From: Avinash Niyas Date: Wed, 31 Dec 2025 06:55:37 +0530 Subject: [PATCH 3/3] formatting Signed-off-by: Avinash Niyas --- .../maven/plugins/scripting/ResourceScriptEvaluator.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/scripting/ResourceScriptEvaluator.java b/src/main/java/org/apache/maven/plugins/scripting/ResourceScriptEvaluator.java index 90d5ffd..5efb062 100644 --- a/src/main/java/org/apache/maven/plugins/scripting/ResourceScriptEvaluator.java +++ b/src/main/java/org/apache/maven/plugins/scripting/ResourceScriptEvaluator.java @@ -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) { @@ -58,7 +58,7 @@ 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 @@ -69,7 +69,7 @@ protected Object eval(ScriptEngine engine, ScriptContext context) throws ScriptE try (InputStream is = this.getClass().getClassLoader().getResourceAsStream(resourceName)) { if (is == null) { - throw new ScriptException("Resource not found : " + resourceName); + throw new ScriptException("Resource not found: " + resourceName); } try (Reader reader = new InputStreamReader(is)) { @@ -80,7 +80,6 @@ protected Object eval(ScriptEngine engine, ScriptContext context) throws ScriptE } } - /** * Gets the script engine by engineName, otherwise by extension of the sciptFile. *