Skip to content

Instantly share code, notes, and snippets.

View felixdo's full-sized avatar
🏠
Working from home

felixdo

🏠
Working from home
View GitHub Profile
@felixdo
felixdo / groovy-in-osgi-env
Created June 15, 2017 11:30
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);