use of org.codehaus.groovy.control.CompilerConfiguration in project groovy by apache.
the class ScriptCompilationExecuter method execute.
public long execute() throws Exception {
ClassLoader cl = new URLClassLoader(classpath, ClassLoader.getSystemClassLoader().getParent());
GroovyClassLoader gcl = new GroovyClassLoader(cl);
CompilationUnit cu = new CompilationUnit(new CompilerConfiguration(), null, gcl, new GroovyClassLoader(this.getClass().getClassLoader()));
for (File source : sources) {
cu.addSource(source);
}
long sd = System.nanoTime();
cu.compile(CompilePhase.CLASS_GENERATION.getPhaseNumber());
long dur = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - sd);
return dur;
}
use of org.codehaus.groovy.control.CompilerConfiguration in project groovy by apache.
the class CompilerTest method setUp.
protected void setUp() throws Exception {
File dir = new File("target/test-generated-classes");
dir.mkdirs();
CompilerConfiguration config = new CompilerConfiguration();
config.setTargetDirectory(dir);
config.setDebug(dumpClass);
compiler = new Compiler(config);
}
use of org.codehaus.groovy.control.CompilerConfiguration in project groovy by apache.
the class FileSystemCompilerTest method setUp.
protected void setUp() throws Exception {
File dir = new File("target/test-generated-classes");
dir.mkdirs();
Map options = new HashMap();
options.put("stubDir", dir);
CompilerConfiguration configuration = new CompilerConfiguration();
configuration.setTargetDirectory(dir);
configuration.setVerbose(dumpClass);
configuration.setJointCompilationOptions(options);
compiler = new FileSystemCompiler(configuration);
}
use of org.codehaus.groovy.control.CompilerConfiguration in project groovy by apache.
the class Groovy7826Bug method testComplexTypeArguments.
public void testComplexTypeArguments() throws Exception {
String script = "def f(org.codehaus.groovy.ast.Groovy7826Bug.C1 c1) { }";
CompilerConfiguration config = new CompilerConfiguration();
config.getOptimizationOptions().put("asmResolving", false);
GroovyShell shell = new GroovyShell(config);
shell.evaluate(script, "bug7826.groovy");
}
use of org.codehaus.groovy.control.CompilerConfiguration in project groovy by apache.
the class GroovyShellTest method testScriptWithDerivedBaseClass.
public void testScriptWithDerivedBaseClass() throws Exception {
Binding context = new Binding();
CompilerConfiguration config = new CompilerConfiguration();
config.setScriptBaseClass(DerivedScript.class.getName());
GroovyShell shell = new GroovyShell(context, config);
Object result = shell.evaluate("x = 'abc'; doSomething(cheese)");
assertEquals("I like Cheddar", result);
assertEquals("abc", context.getVariable("x"));
}
Aggregations