Class GroovyCompiler
- java.lang.Object
- org.springframework.boot.cli.compiler.GroovyCompiler
public class GroovyCompiler extends Object
Compiler for Groovy sources. Primarily a simple Facade forGroovyClassLoader.parseClass(GroovyCodeSource)
with the following additional features:CompilerAutoConfiguration
strategies will be read fromMETA-INF/services/org.springframework.boot.cli.compiler.CompilerAutoConfiguration
(per the standard javaServiceLoader
contract) and applied during compilation- Multiple classes can be returned if the Groovy source defines more than one Class
- Generated class files can also be loaded using
ClassLoader.getResource(String)
Constructor Summary
Constructors Constructor Description GroovyCompiler(GroovyCompilerConfiguration configuration)
Create a newGroovyCompiler
instance.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addCompilationCustomizers(org.codehaus.groovy.control.customizers.CompilationCustomizer... customizers)
Class<?>[]
compile(String... sources)
Compile the specified Groovy sources, applying anyCompilerAutoConfiguration
s.List<org.codehaus.groovy.transform.ASTTransformation>
getAstTransformations()
Return a mutable list of theASTTransformation
s to be applied duringcompile(String...)
.ExtendedGroovyClassLoader
getLoader()
Constructor Detail
GroovyCompiler
public GroovyCompiler(GroovyCompilerConfiguration configuration)
Create a newGroovyCompiler
instance.- Parameters:
configuration
- the compiler configuration
Method Detail
getAstTransformations
public List<org.codehaus.groovy.transform.ASTTransformation> getAstTransformations()
Return a mutable list of theASTTransformation
s to be applied duringcompile(String...)
.- Returns:
- the AST transformations to apply
getLoader
public ExtendedGroovyClassLoader getLoader()
addCompilationCustomizers
public void addCompilationCustomizers(org.codehaus.groovy.control.customizers.CompilationCustomizer... customizers)
compile
public Class<?>[] compile(String... sources) throws org.codehaus.groovy.control.CompilationFailedException, IOException
Compile the specified Groovy sources, applying anyCompilerAutoConfiguration
s. All classes defined in the sources will be returned from this method.- Parameters:
sources
- the sources to compile- Returns:
- compiled classes
- Throws:
org.codehaus.groovy.control.CompilationFailedException
- in case of compilation failuresIOException
- in case of I/O errorsorg.codehaus.groovy.control.CompilationFailedException
- in case of compilation errors