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

public class JavaAwareCompilationUnit extends CompilationUnit
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, sources`

  ### Fields inherited from class org.codehaus.groovy.control.ProcessingUnit

  `classLoader, configuration, errorCollector, phase, phaseComplete`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `JavaAwareCompilationUnit()`
  Creates 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 Type
  Method
  Description
  `void`
  `addSources(File[] files)`
  Adds Groovy or Java sources from the supplied files.
  `void`
  `addSources(String[] paths)`
  Adds Groovy or Java sources from the supplied path strings.
  `void`
  `configure(CompilerConfiguration configuration)`
  Configures the compilation unit and ensures the target directory is on the Groovy class loader classpath.
  `JavaCompilerFactory`
  `getCompilerFactory()`
  Returns the factory used to create the backing Java compiler.
  `void`
  `gotoPhase(int phase)`
  Advances the compilation unit to the requested phase and triggers javac when the semantic analysis boundary is reached.
  `void`
  `setCompilerFactory(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, setProgressCallback`

  ### Methods inherited from class org.codehaus.groovy.control.ProcessingUnit

  `completePhase, getClassLoader, getConfiguration, getErrorCollector, getPhase, getPhaseDescription, isPhaseComplete, nextPhase, setClassLoader, setConfiguration`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### JavaAwareCompilationUnit

    public JavaAwareCompilationUnit()
    Creates a joint compilation unit with the default configuration.

  - ### JavaAwareCompilationUnit

    public JavaAwareCompilationUnit(CompilerConfiguration configuration)
    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 use
      `groovyClassLoader` - 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 use
      `groovyClassLoader` - the Groovy class loader to use
      `transformClassLoader` - the class loader used for AST transforms

- ## Method Details

  - ### gotoPhase

    public void gotoPhase(int phase) throws CompilationFailedException
    Advances the compilation unit to the requested phase and triggers javac when the semantic analysis boundary is reached.
    Overrides:
      `gotoPhase` in class `ProcessingUnit`
    Parameters:
      `phase` - the target compilation phase
    Throws:
      `CompilationFailedException` - if compilation fails

  - ### configure

    public void configure(CompilerConfiguration configuration)
    Configures the compilation unit and ensures the target directory is on the Groovy class loader classpath.
    Overrides:
      `configure` in class `CompilationUnit`
    Parameters:
      `configuration` - the compiler configuration to apply

  - ### addSources

    public void addSources(String[] paths)
    Adds Groovy or Java sources from the supplied path strings.
    Overrides:
      `addSources` in class `CompilationUnit`
    Parameters:
      `paths` - the source paths to add

  - ### addSources

    public void addSources(File[] files)
    Adds Groovy or Java sources from the supplied files.
    Overrides:
      `addSources` in class `CompilationUnit`
    Parameters:
      `files` - the source files to add

  - ### getCompilerFactory

    public JavaCompilerFactory getCompilerFactory()
    Returns the factory used to create the backing Java compiler.
    Returns:
      the Java compiler factory

  - ### setCompilerFactory

    public void setCompilerFactory(JavaCompilerFactory compilerFactory)
    Sets the factory used to create the backing Java compiler.
    Parameters:
      `compilerFactory` - the Java compiler factory to use