From dc6cc5e9c144d0b97a12fd01d435a6b3375b7bb0 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Mon, 14 Apr 2014 07:18:49 +0000 Subject: [PATCH] * move groovy default imports into ScriptShell.properties --- .../org.codehaus.groovy.runtime.ExtensionModule | 7 +++---- source/net/sourceforge/filebot/cli/ScriptShell.java | 12 ++++++------ .../sourceforge/filebot/cli/ScriptShell.properties | 3 +++ .../sourceforge/filebot/media/MediaDetection.java | 4 ++-- 4 files changed, 14 insertions(+), 12 deletions(-) create mode 100644 source/net/sourceforge/filebot/cli/ScriptShell.properties diff --git a/source/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule b/source/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule index 5cde43d4..4ecc81a6 100644 --- a/source/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule +++ b/source/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule @@ -1,4 +1,3 @@ -moduleName=filebot-groovy-all -moduleVersion=4.1 -extensionClasses=net.sourceforge.filebot.cli.ScriptShellMethods,net.sourceforge.filebot.format.ExpressionFormatMethods,org.codehaus.groovy.jsr223.ScriptExtensions -staticExtensionClasses=org.codehaus.groovy.jsr223.ScriptStaticExtensions +moduleName=filebot-scripting-extension +moduleVersion=4.0 +extensionClasses=net.sourceforge.filebot.cli.ScriptShellMethods,net.sourceforge.filebot.format.ExpressionFormatMethods diff --git a/source/net/sourceforge/filebot/cli/ScriptShell.java b/source/net/sourceforge/filebot/cli/ScriptShell.java index 0474c1df..0df2b46d 100644 --- a/source/net/sourceforge/filebot/cli/ScriptShell.java +++ b/source/net/sourceforge/filebot/cli/ScriptShell.java @@ -20,6 +20,7 @@ import java.util.LinkedHashMap; import java.util.Map; import java.util.Map.Entry; import java.util.PropertyPermission; +import java.util.ResourceBundle; import javax.script.Bindings; import javax.script.ScriptContext; @@ -56,18 +57,17 @@ public class ScriptShell { } public ScriptEngine createScriptEngine() { + ResourceBundle bundle = ResourceBundle.getBundle(ScriptShell.class.getName()); + CompilerConfiguration config = new CompilerConfiguration(); - config.setScriptBaseClass("net.sourceforge.filebot.cli.ScriptShellBaseClass"); + config.setScriptBaseClass(bundle.getString("scriptBaseClass")); config.setRecompileGroovySource(false); config.setDebug(false); // default imports ImportCustomizer imports = new ImportCustomizer(); - imports.addStarImports("net.sourceforge.filebot", "net.sourceforge.filebot.util", "net.sourceforge.filebot.web", "net.sourceforge.filebot.media", "net.sourceforge.filebot.mediainfo", "net.sourceforge.filebot.hash"); - imports.addStaticStars("net.sourceforge.filebot.WebServices"); - imports.addStarImports("groovy.io", "groovy.xml", "groovy.json", "org.jsoup"); - imports.addStarImports("java.nio.file", "java.nio.file.attribute", "java.util.regex"); - imports.addStaticStars("java.nio.file.Files"); + imports.addStarImports(bundle.getString("starImport").split(", ")); + imports.addStaticStars(bundle.getString("starStaticImport").split(", ")); config.addCompilationCustomizers(imports); GroovyClassLoader classLoader = new GroovyClassLoader(Thread.currentThread().getContextClassLoader(), config); diff --git a/source/net/sourceforge/filebot/cli/ScriptShell.properties b/source/net/sourceforge/filebot/cli/ScriptShell.properties new file mode 100644 index 00000000..a1d73db7 --- /dev/null +++ b/source/net/sourceforge/filebot/cli/ScriptShell.properties @@ -0,0 +1,3 @@ +scriptBaseClass: net.sourceforge.filebot.cli.ScriptShellBaseClass +starImport: net.sourceforge.filebot, net.sourceforge.filebot.util, net.sourceforge.filebot.web, net.sourceforge.filebot.media, net.sourceforge.filebot.mediainfo, net.sourceforge.filebot.hash, net.sourceforge.filebot.similarity, groovy.io, groovy.xml, groovy.json, org.jsoup, java.nio.file, java.nio.file.attribute, java.util.regex +starStaticImport: net.sourceforge.filebot.WebServices, net.sourceforge.filebot.media.MediaDetection, java.nio.file.Files \ No newline at end of file diff --git a/source/net/sourceforge/filebot/media/MediaDetection.java b/source/net/sourceforge/filebot/media/MediaDetection.java index 3f846c42..47017921 100644 --- a/source/net/sourceforge/filebot/media/MediaDetection.java +++ b/source/net/sourceforge/filebot/media/MediaDetection.java @@ -282,10 +282,10 @@ public class MediaDetection { if (useAnimeIndex) index.addAll(getAnimeIndex()); - return detectSeriesNames(files, locale, index); + return detectSeriesNames(files, index, locale); } - public static List detectSeriesNames(Collection files, Locale locale, List> index) throws Exception { + public static List detectSeriesNames(Collection files, List> index, Locale locale) throws Exception { List names = new ArrayList(); // try xattr metadata if enabled