Package: org.codehaus.groovy.tools.javac

## [Java] Class JavaStubCompilationUnit

- org.codehaus.groovy.tools.javac.JavaStubCompilationUnit

-     public class JavaStubCompilationUnit
      extends CompilationUnit

  Compilation unit to only generate stubs.

- - Inherited fields
    Fields inherited from class | Fields
    --- | ---
    `class CompilationUnit` | `ast, astTransformationsContext, classNodeResolver, classgenCallback, configured, debug, progressCallback, queuedSources, resolveVisitor, sources`
    `class ProcessingUnit` | `classLoader, configuration, errorCollector, phase, phaseComplete`

  - ### Constructor Summary

    Constructors
    Constructor and description
    `JavaStubCompilationUnit(CompilerConfiguration config, GroovyClassLoader gcl, File destDir)` Creates a compilation unit that generates Java stubs into the supplied destination directory.
    `JavaStubCompilationUnit(CompilerConfiguration config, GroovyClassLoader gcl)` Creates a compilation unit that generates Java stubs into the configured stub directory.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public SourceUnit` | `addSource(File file)` Adds a source file when its extension is accepted for stub generation.
    `` | `public SourceUnit` | `addSource(URL url)` Adds a source URL when its extension is accepted for stub generation.
    `` | `public void` | `compile()` Compiles sources through the conversion phase to generate stubs only.
    `` | `public void` | `configure(CompilerConfiguration config)` Configures the compilation unit and makes the target directory visible to the Groovy class loader.
    `` | `public int` | `getStubCount()` Returns the number of stubs generated during the last compilation run.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class CompilationUnit` | `addClassNode, addFirstPhaseOperation, addFirstPhaseOperation, addJavaCompilationUnits, addNewPhaseOperation, addNewPhaseOperation, addPhaseOperation, addPhaseOperation, addPhaseOperation, addPhaseOperation, addPhaseOperation, addPhaseOperation, addSource, addSource, addSource, addSource, addSource, addSources, addSources, applyToPrimaryClassNodes, applyToSourceUnits, compile, compile, configure, createClassVisitor, dequeued, getAST, getASTTransformationsContext, getClassNode, getClassNodeResolver, getClasses, getClassgenCallback, getFirstClassNode, getJavaCompilationUnitSet, getProgressCallback, getTransformLoader, iterator, mark, setClassNodeResolver, setClassgenCallback, setProgressCallback`
    `class ProcessingUnit` | `completePhase, configure, getClassLoader, getConfiguration, getErrorCollector, getPhase, getPhaseDescription, gotoPhase, isPhaseComplete, nextPhase, setClassLoader, setConfiguration`

- - ### Constructor Detail

    - #### public JavaStubCompilationUnit(CompilerConfiguration config, GroovyClassLoader gcl, File destDir)

      Creates a compilation unit that generates Java stubs into the supplied destination directory.

      Parameters:
        `config` - the compiler configuration
        `gcl` - the Groovy class loader to use
        `destDir` - the destination directory for generated stubs

    - #### public JavaStubCompilationUnit(CompilerConfiguration config, GroovyClassLoader gcl)

      Creates a compilation unit that generates Java stubs into the configured stub directory.

      Parameters:
        `config` - the compiler configuration
        `gcl` - the Groovy class loader to use

  - ### Method Detail

    - #### public SourceUnit addSource(File file)

      Adds a source file when its extension is accepted for stub generation.

      Parameters:
        `file` - the source file to add
      Returns:
        the created source unit, or `null` if the extension is not accepted

    - #### public SourceUnit addSource(URL url)

      Adds a source URL when its extension is accepted for stub generation.

      Parameters:
        `url` - the source URL to add
      Returns:
        the created source unit, or `null` if the extension is not accepted

    - #### public void compile()

      Compiles sources through the conversion phase to generate stubs only.

      throws:
        CompilationFailedException if stub generation fails

    - #### public void configure(CompilerConfiguration config)

      Configures the compilation unit and makes the target directory visible to the Groovy class loader.

      Parameters:
        `config` - the compiler configuration to apply

    - #### public int getStubCount()

      Returns the number of stubs generated during the last compilation run.

      Returns:
        the generated stub count