Class JavaAwareCompilationUnit


public class JavaAwareCompilationUnit extends CompilationUnit
Compilation Unit capable of compiling Java source files.
  • 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