addImports(...)
method accept both path for classes or for packages[1]
wrapper.addImports("java.util.List", "my.package.*");Note that it is possible to clear the default import declarations previously set on a wrapper by ScriptWrapper.clearImports().
java.util.List
interface.
ScriptWrapper<Script> wrapper = new GroovyScriptWrapper<Script>() { protected Set<lt;String> getCustomDefaultImports() { Set<String> set = new TreeSet<>(); set.add("java.util.List"); return set; } }; Script Script = wrapper.getScript(); File file = new File(<our script file>); wrapper.installScript(file);
ScriptWrapper<Script> wrapper = new GroovyScriptWrapper<Script>() { }; wrapper.addImports("java.util.List"); Script Script = wrapper.getScript(); File file = new File(<our script file>); wrapper.installScript(file);
Copyright 2019-2020 Herve Girod. All Rights Reserved. Documentation and source under the BSD licence