Skip to content

Instantly share code, notes, and snippets.

@mariogarcia
Forked from felixdo/groovy-in-osgi-env
Created June 15, 2017 12:13
Show Gist options
  • Save mariogarcia/fa8f611b0dfdaa605e53855153ebf895 to your computer and use it in GitHub Desktop.
Save mariogarcia/fa8f611b0dfdaa605e53855153ebf895 to your computer and use it in GitHub Desktop.
run scripts from inside eclipse workbench
Bundle groovy = Platform.getBundle("org.codehaus.groovy");
final GroovyClassLoader transformLoader = new GroovyClassLoader(groovy.adapt(BundleWiring.class).getClassLoader());
GroovyClassLoader loader = new GroovyClassLoader(getClass().getClassLoader()) {
@Override
protected CompilationUnit createCompilationUnit(CompilerConfiguration config, CodeSource source) {
return new CompilationUnit(config, source, this, transformLoader, true, null, null);
}
};
Class<?> cl = loader.parseClass(new GroovyCodeSource(capellaScriptFile.getLocation().toFile(), capellaScriptFile.getCharset()));
InvokerHelper.runScript(cl, args);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment