Package org.codehaus.groovy.tools.javac
Class JavaAwareCompilationUnit
java.lang.Object
org.codehaus.groovy.control.ProcessingUnit
org.codehaus.groovy.control.CompilationUnit
org.codehaus.groovy.tools.javac.JavaAwareCompilationUnit
Compilation Unit capable of compiling Java source files.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.codehaus.groovy.control.CompilationUnit
CompilationUnit.ClassgenCallback, CompilationUnit.GroovyClassOperation, CompilationUnit.IGroovyClassOperation, CompilationUnit.IPrimaryClassNodeOperation, CompilationUnit.ISourceUnitOperation, CompilationUnit.PrimaryClassNodeOperation, CompilationUnit.ProgressCallback, CompilationUnit.SourceUnitOperation -
Field Summary
Fields inherited from class org.codehaus.groovy.control.CompilationUnit
ast, astTransformationsContext, classgenCallback, classNodeResolver, configured, debug, progressCallback, queuedSources, resolveVisitor, sourcesFields inherited from class org.codehaus.groovy.control.ProcessingUnit
classLoader, configuration, errorCollector, phase, phaseComplete -
Constructor Summary
ConstructorsConstructorDescriptionCreates a joint compilation unit with the default configuration.JavaAwareCompilationUnit(CompilerConfiguration configuration) Creates a joint compilation unit with the supplied configuration.JavaAwareCompilationUnit(CompilerConfiguration configuration, GroovyClassLoader groovyClassLoader) Creates a joint compilation unit with the supplied configuration and class loader.JavaAwareCompilationUnit(CompilerConfiguration configuration, GroovyClassLoader groovyClassLoader, GroovyClassLoader transformClassLoader) Creates a joint compilation unit with explicit Groovy and transform class loaders. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSources(File[] files) Adds Groovy or Java sources from the supplied files.voidaddSources(String[] paths) Adds Groovy or Java sources from the supplied path strings.voidconfigure(CompilerConfiguration configuration) Configures the compilation unit and ensures the target directory is on the Groovy class loader classpath.Returns the factory used to create the backing Java compiler.voidgotoPhase(int phase) Advances the compilation unit to the requested phase and triggers javac when the semantic analysis boundary is reached.voidsetCompilerFactory(JavaCompilerFactory compilerFactory) Sets the factory used to create the backing Java compiler.Methods inherited from class org.codehaus.groovy.control.CompilationUnit
addClassNode, addFirstPhaseOperation, addFirstPhaseOperation, addJavaCompilationUnits, addNewPhaseOperation, addNewPhaseOperation, addPhaseOperation, addPhaseOperation, addPhaseOperation, addPhaseOperation, addPhaseOperation, addPhaseOperation, addSource, addSource, addSource, addSource, addSource, applyToPrimaryClassNodes, applyToSourceUnits, compile, compile, createClassVisitor, dequeued, getAST, getASTTransformationsContext, getClasses, getClassgenCallback, getClassNode, getClassNodeResolver, getFirstClassNode, getJavaCompilationUnitSet, getProgressCallback, getTransformLoader, iterator, mark, setClassgenCallback, setClassNodeResolver, setProgressCallbackMethods inherited from class org.codehaus.groovy.control.ProcessingUnit
completePhase, getClassLoader, getConfiguration, getErrorCollector, getPhase, getPhaseDescription, isPhaseComplete, nextPhase, setClassLoader, setConfiguration
-
Constructor Details
-
JavaAwareCompilationUnit
public JavaAwareCompilationUnit()Creates a joint compilation unit with the default configuration. -
JavaAwareCompilationUnit
Creates a joint compilation unit with the supplied configuration.- Parameters:
configuration- the compiler configuration to use
-
JavaAwareCompilationUnit
public JavaAwareCompilationUnit(CompilerConfiguration configuration, GroovyClassLoader groovyClassLoader) Creates a joint compilation unit with the supplied configuration and class loader.- Parameters:
configuration- the compiler configuration to usegroovyClassLoader- the Groovy class loader to use
-
JavaAwareCompilationUnit
public JavaAwareCompilationUnit(CompilerConfiguration configuration, GroovyClassLoader groovyClassLoader, GroovyClassLoader transformClassLoader) Creates a joint compilation unit with explicit Groovy and transform class loaders.- Parameters:
configuration- the compiler configuration to usegroovyClassLoader- the Groovy class loader to usetransformClassLoader- the class loader used for AST transforms
-
-
Method Details
-
gotoPhase
Advances the compilation unit to the requested phase and triggers javac when the semantic analysis boundary is reached.- Overrides:
gotoPhasein classProcessingUnit- Parameters:
phase- the target compilation phase- Throws:
CompilationFailedException- if compilation fails
-
configure
Configures the compilation unit and ensures the target directory is on the Groovy class loader classpath.- Overrides:
configurein classCompilationUnit- Parameters:
configuration- the compiler configuration to apply
-
addSources
Adds Groovy or Java sources from the supplied path strings.- Overrides:
addSourcesin classCompilationUnit- Parameters:
paths- the source paths to add
-
addSources
Adds Groovy or Java sources from the supplied files.- Overrides:
addSourcesin classCompilationUnit- Parameters:
files- the source files to add
-
getCompilerFactory
Returns the factory used to create the backing Java compiler.- Returns:
- the Java compiler factory
-
setCompilerFactory
Sets the factory used to create the backing Java compiler.- Parameters:
compilerFactory- the Java compiler factory to use
-