Github user markap14 commented on a diff in the pull request:
https://github.com/apache/nifi/pull/203#discussion_r51731945
--- Diff:
nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/processors/script/impl/GroovyScriptEngineConfigurator.java
---
@@ -42,13 +49,56 @@ public String getScriptEngineName() {
}
@Override
- public Object init(ScriptEngine engine, String modulePath) throws
ScriptException {
+ public URL[] getModuleURLsForClasspath(String[] modulePaths,
ComponentLog log) {
+ List<URL> additionalClasspath = new LinkedList<>();
+ if (modulePaths != null) {
+ for (String modulePathString : modulePaths) {
+ File modulePath = new File(modulePathString);
+
+ if (modulePath.exists()) {
+ // Add the URL of this path
+ try {
+
additionalClasspath.add(modulePath.toURI().toURL());
+ } catch (MalformedURLException mue) {
+ log.error("{} is not a valid file/folder,
ignoring", new Object[]{modulePath.getAbsolutePath()}, mue);
+ }
+
+ // If the path is a directory, we need to scan for
JARs and add them to the classpath
+ if (modulePath.isDirectory()) {
+ File[] jarFiles = modulePath.listFiles(new
FilenameFilter() {
+ @Override
+ public boolean accept(File dir, String name) {
+ return (name != null &&
name.endsWith(".jar"));
+ }
+ });
+
+ if (jarFiles != null) {
+ // Add each to the classpath
+ for (File jarFile : jarFiles) {
+ try {
+
additionalClasspath.add(jarFile.toURI().toURL());
+
+ } catch (MalformedURLException mue) {
+ log.error("{} is not a valid
file/folder, ignoring", new Object[]{modulePath.getAbsolutePath()}, mue);
+ }
+ }
+ }
+ }
+ }
+ log.info("{} does not exist, ignoring", new
Object[]{modulePath.getAbsolutePath()});
--- End diff --
I think this is supposed to go in an 'else' :)
Also, can we change this to a WARN level instead of INFO please?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---