Search in sources :

Example 41 with CompilationUnit

use of org.codehaus.groovy.control.CompilationUnit in project grails-core by grails.

the class GrailsAwareClassLoader method createCompilationUnit.

/**
 * @see groovy.lang.GroovyClassLoader#createCompilationUnit(org.codehaus.groovy.control.CompilerConfiguration, java.security.CodeSource)
 */
@Override
protected CompilationUnit createCompilationUnit(CompilerConfiguration config, CodeSource source) {
    CompilationUnit cu = super.createCompilationUnit(config, source);
    GrailsAwareInjectionOperation operation;
    if (classInjectors == null) {
        operation = new GrailsAwareInjectionOperation();
    } else {
        operation = new GrailsAwareInjectionOperation(classInjectors);
    }
    cu.addPhaseOperation(operation, Phases.CANONICALIZATION);
    return cu;
}
Also used : CompilationUnit(org.codehaus.groovy.control.CompilationUnit)

Example 42 with CompilationUnit

use of org.codehaus.groovy.control.CompilationUnit in project freeplane by freeplane.

the class ScriptCompiler method compile.

private static void compile(File dir, File[] files) {
    try {
        final CompilerConfiguration compilerConfiguration = GroovyScript.createCompilerConfiguration();
        compilerConfiguration.setTargetDirectory(dir);
        final CompilationUnit unit = new CompilationUnit(compilerConfiguration, null, new GroovyClassLoader(ScriptingEngine.class.getClassLoader()));
        new FileSystemCompiler(compilerConfiguration, unit).compile(files);
        LogUtils.info("compiled in " + dir + ": " + createNameList(files));
    } catch (Exception e) {
        LogUtils.severe("error compiling in " + dir + createNameList(files), e);
    }
}
Also used : CompilationUnit(org.codehaus.groovy.control.CompilationUnit) GroovyClassLoader(groovy.lang.GroovyClassLoader) FileSystemCompiler(org.codehaus.groovy.tools.FileSystemCompiler) CompilerConfiguration(org.codehaus.groovy.control.CompilerConfiguration)

Aggregations

CompilationUnit (org.codehaus.groovy.control.CompilationUnit)42 SourceUnit (org.codehaus.groovy.control.SourceUnit)13 CompilerConfiguration (org.codehaus.groovy.control.CompilerConfiguration)12 ClassNode (org.codehaus.groovy.ast.ClassNode)11 GroovyClassLoader (groovy.lang.GroovyClassLoader)9 File (java.io.File)8 ArrayList (java.util.ArrayList)8 URL (java.net.URL)7 GroovyClass (org.codehaus.groovy.tools.GroovyClass)7 IOException (java.io.IOException)6 List (java.util.List)5 BuildException (org.apache.tools.ant.BuildException)5 HashMap (java.util.HashMap)4 LinkedHashMap (java.util.LinkedHashMap)4 LinkedHashSet (java.util.LinkedHashSet)4 Map (java.util.Map)4 ErrorCollector (org.codehaus.groovy.control.ErrorCollector)4 JavaAwareCompilationUnit (org.codehaus.groovy.tools.javac.JavaAwareCompilationUnit)4 GroovyObject (groovy.lang.GroovyObject)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)3