Skip to content

Instantly share code, notes, and snippets.

@felixdo
Created June 15, 2017 11:30
Show Gist options
  • Save felixdo/ca6d46ab54a95791800ced4e6f3a8f05 to your computer and use it in GitHub Desktop.
Save felixdo/ca6d46ab54a95791800ced4e6f3a8f05 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