Modifier and Type | Class and Description |
---|---|
static class |
DefaultGroovyCompiler.Builder
Builder for instances of
DefaultGroovyCompiler . |
Modifier | Constructor and Description |
---|---|
|
DefaultGroovyCompiler()
constructor from parent class loader set to the context class loader of the current thread
and from default compiler configuration.
|
|
DefaultGroovyCompiler(ClassLoader parent)
constructor from given parent class loader and default compiler configuration.
|
|
DefaultGroovyCompiler(ClassLoader parent,
org.codehaus.groovy.control.CompilerConfiguration config)
constructor from given parent class loader and compiler configuration.
|
protected |
DefaultGroovyCompiler(DefaultGroovyCompiler.Builder builder)
constructor from builder.
|
Modifier and Type | Method and Description |
---|---|
protected org.codehaus.groovy.control.SourceUnit |
addToCompilationUnit(org.codehaus.groovy.control.CompilationUnit cu,
Source source,
Sources sources)
adds the given source to the given compilation unit and returns the resulting source unit.
|
Code |
compile(Sources sources)
compiles the given Groovy script sources to an instance of
Code in memory. |
static void |
disableGrapeSupport()
disable Grape support.
|
static void |
enableGrapeSupport()
enable Grape support with the
Grape class as lock. |
static void |
enableGrapeSupport(Object lock)
enable Grape support with the given class as lock.
|
DefaultGroovyCompiler.Builder |
getBuilder()
gets the builder.
|
org.codehaus.groovy.control.CompilerConfiguration |
getCompilerConfiguration()
gets the compiler configuration.
|
ClassLoader |
getParent()
gets the parent class loader.
|
static org.codehaus.groovy.control.CompilerConfiguration |
withGrape(org.codehaus.groovy.control.CompilerConfiguration config,
groovy.lang.GroovyClassLoader runtimeLoader)
modifies the given compiler configuration for Grape support in this compiler.
|
protected DefaultGroovyCompiler(DefaultGroovyCompiler.Builder builder)
builder
- builderpublic DefaultGroovyCompiler()
public DefaultGroovyCompiler(ClassLoader parent)
parent
- parent class loaderNullPointerException
- if the parent class loader is nullpublic DefaultGroovyCompiler(ClassLoader parent, org.codehaus.groovy.control.CompilerConfiguration config)
parent
- parent class loaderconfig
- compiler configurationNullPointerException
- if the parent class loader or the compiler configuration is nullpublic static org.codehaus.groovy.control.CompilerConfiguration withGrape(org.codehaus.groovy.control.CompilerConfiguration config, groovy.lang.GroovyClassLoader runtimeLoader)
Only has an effect during compilation if Grape support had been enabled and only with this compiler class.
config
- compiler configuration to enable for GraperuntimeLoader
- the GroovyClassLoader that is intended to be used later
as a parent loader when loading classes compiled with
the given compiler configurationNullPointerException
- if the compiler configuration is nullpublic static void enableGrapeSupport()
Grape
class as lock.
Currently wraps the GrapeEngine
in the Grape
class with
a wrapper that fixes an open Groovy issue (GROOVY-7407) using the lock
and provides a mechanism needed for Grape with Grengine. See user manual
under "Grengine and Grape" for more information.
Call once before using this compiler class in combination with Grengine
(equivalent to calling Grengine.Grape.activate()
).
public static void enableGrapeSupport(Object lock)
Currently wraps the GrapeEngine
in the Grape
class with
a wrapper that fixes an open Groovy issue (GROOVY-7407) using the lock
and provides a mechanism needed for Grape with Grengine. See user manual
under "Grengine and Grape" for more information.
Call once before using this compiler class in combination with Grengine
(equivalent to calling Grengine.Grape.activate(lock)
).
lock
- the lock to useNullPointerException
- if the lock is nullpublic static void disableGrapeSupport()
Currently unwraps the GrapeEngine
in the Grape
.
See user manual under "Grengine and Grape" for more information.
Call once when done using this compiler class in combination with Grengine
(equivalent to calling Grengine.Grape.deactivate()
).
public Code compile(Sources sources)
Code
in memory.
If CompilerConfiguration.getTargetDirectory()
is not null,
class files are also written to the target directory.
compile
in interface Compiler
sources
- sourcesCompileException
- if compilation failedNullPointerException
- if sources are nullprotected org.codehaus.groovy.control.SourceUnit addToCompilationUnit(org.codehaus.groovy.control.CompilationUnit cu, Source source, Sources sources)
cu
- compilation unitsource
- sourcesources
- all sources, needed only if the type of source is unsupported,
for the resulting CompileException
CompileException
- if the type of source is unsupportedpublic DefaultGroovyCompiler.Builder getBuilder()
public ClassLoader getParent()
public org.codehaus.groovy.control.CompilerConfiguration getCompilerConfiguration()