Skip to content

Instantly share code, notes, and snippets.

@sazzer
Created August 19, 2012 16:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sazzer/3396114 to your computer and use it in GitHub Desktop.
Save sazzer/3396114 to your computer and use it in GitHub Desktop.
Loading Groovy scripts as classes at runtime
public class GroovyClassloaderTest {
@Test
public void loadGroovyScript() throws Exception {
CompilerConfiguration compilerConfiguration = new CompilerConfiguration();
compilerConfiguration.setClasspath("/base/directory/containing/groovy/files");
GroovyClassLoader gcl = new GroovyClassLoader(getClass().getClassLoader(), compilerConfiguration);
Class<?> cls = gcl.loadClass("SampleClass", true, true, true);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment