Package org.codehaus.groovy.ant

# Class CompileTaskSupport

java.lang.Object
org.apache.tools.ant.ProjectComponent
org.apache.tools.ant.Task
org.apache.tools.ant.taskdefs.MatchingTask
org.codehaus.groovy.ant.CompileTaskSupport

All Implemented Interfaces:
  `Cloneable`, `org.apache.tools.ant.types.selectors.SelectorContainer`

Direct Known Subclasses:
  `GenerateStubsTask`, `GroovycTask`

public abstract class CompileTaskSupport extends org.apache.tools.ant.taskdefs.MatchingTask
Support for compilation related tasks.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected org.apache.tools.ant.types.Path`
  `classpath`
  Compilation classpath.
  `protected CompilerConfiguration`
  `config`
  Compiler configuration shared with the concrete task implementation.
  `protected File`
  `destdir`
  Destination directory for generated output.
  `protected boolean`
  `failOnError`
  Whether task failures should stop the Ant build.
  `protected final LoggingHelper`
  `log`
  Logger used by subclasses to report task progress.
  `protected org.apache.tools.ant.types.Path`
  `src`
  Source roots to scan for compilation inputs.

  ### Fields inherited from class org.apache.tools.ant.taskdefs.MatchingTask

  `fileset`

  ### Fields inherited from class org.apache.tools.ant.Task

  `target, taskName, taskType, wrapper`

  ### Fields inherited from class org.apache.tools.ant.ProjectComponent

  `description, location, project`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `CompileTaskSupport()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected abstract void`
  `compile()`
  Performs the concrete compilation work for the task.
  `protected GroovyClassLoader`
  `createClassLoader()`
  Creates a class loader for the current compiler configuration and classpath.
  `org.apache.tools.ant.types.Path`
  `createClasspath()`
  Creates a nested `<classpath>` path element.
  `CompilerConfiguration`
  `createConfiguration()`
  Returns the mutable compiler configuration used by this task.
  `org.apache.tools.ant.types.Path`
  `createSrc()`
  Creates a nested `<src>` path element.
  `void`
  `execute()`
  Validates the task and delegates to `compile()`.
  `org.apache.tools.ant.types.Path`
  `getClasspath()`
  Returns the configured compilation classpath.
  `boolean`
  `getFailonerror()`
  Indicates whether compilation errors fail the Ant build.
  `org.apache.tools.ant.types.Path`
  `getSrcdir()`
  Returns the configured source roots.
  `protected void`
  `handleException(Exception e)`
  Converts a compilation failure into the Ant task's configured error handling.
  `void`
  `setClasspath(org.apache.tools.ant.types.Path path)`
  Adds entries to the compilation classpath.
  `void`
  `setClasspathRef(org.apache.tools.ant.types.Reference r)`
  Adds a reference to a classpath defined elsewhere.
  `void`
  `setDestdir(File dir)`
  Sets the output directory for generated classes or stubs.
  `void`
  `setFailonerror(boolean fail)`
  Controls whether compilation errors should fail the Ant build.
  `void`
  `setSrcdir(org.apache.tools.ant.types.Path dir)`
  Adds source roots to the task.
  `protected void`
  `validate()`
  Validates the task configuration before compilation starts.

  ### Methods inherited from class org.apache.tools.ant.taskdefs.MatchingTask

  `add, addAnd, addContains, addContainsRegexp, addCustom, addDate, addDepend, addDepth, addDifferent, addFilename, addMajority, addModified, addNone, addNot, addOr, addPresent, addSelector, addSize, addType, appendSelector, createExclude, createExcludesFile, createInclude, createIncludesFile, createPatternSet, getDirectoryScanner, getImplicitFileSet, getSelectors, hasSelectors, selectorCount, selectorElements, setCaseSensitive, setDefaultexcludes, setExcludes, setExcludesfile, setFollowSymlinks, setIncludes, setIncludesfile, setProject, XsetIgnore, XsetItems`

  ### Methods inherited from class org.apache.tools.ant.Task

  `bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType`

  ### Methods inherited from class org.apache.tools.ant.ProjectComponent

  `clone, getDescription, getLocation, getProject, setDescription, setLocation`

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

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

- ## Field Details

  - ### log

    protected final LoggingHelper log
    Logger used by subclasses to report task progress.

  - ### src

    protected org.apache.tools.ant.types.Path src
    Source roots to scan for compilation inputs.

  - ### destdir

    protected File destdir
    Destination directory for generated output.

  - ### classpath

    protected org.apache.tools.ant.types.Path classpath
    Compilation classpath.

  - ### config

    protected CompilerConfiguration config
    Compiler configuration shared with the concrete task implementation.

  - ### failOnError

    protected boolean failOnError
    Whether task failures should stop the Ant build.

- ## Constructor Details

  - ### CompileTaskSupport

    public CompileTaskSupport()

- ## Method Details

  - ### setFailonerror

    public void setFailonerror(boolean fail)
    Controls whether compilation errors should fail the Ant build.
    Parameters:
      `fail` - `true` to fail the build on compilation errors

  - ### getFailonerror

    public boolean getFailonerror()
    Indicates whether compilation errors fail the Ant build.
    Returns:
      `true` if failures abort the build

  - ### createSrc

    public org.apache.tools.ant.types.Path createSrc()
    Creates a nested `<src>` path element.
    Returns:
      the path element to configure

  - ### setSrcdir

    public void setSrcdir(org.apache.tools.ant.types.Path dir)
    Adds source roots to the task.
    Parameters:
      `dir` - the source path to append

  - ### getSrcdir

    public org.apache.tools.ant.types.Path getSrcdir()
    Returns the configured source roots.
    Returns:
      the source path

  - ### setDestdir

    public void setDestdir(File dir)
    Sets the output directory for generated classes or stubs.
    Parameters:
      `dir` - the destination directory

  - ### setClasspath

    public void setClasspath(org.apache.tools.ant.types.Path path)
    Adds entries to the compilation classpath.
    Parameters:
      `path` - the classpath entries to append

  - ### getClasspath

    public org.apache.tools.ant.types.Path getClasspath()
    Returns the configured compilation classpath.
    Returns:
      the compilation classpath

  - ### createClasspath

    public org.apache.tools.ant.types.Path createClasspath()
    Creates a nested `<classpath>` path element.
    Returns:
      the path element to configure

  - ### setClasspathRef

    public void setClasspathRef(org.apache.tools.ant.types.Reference r)
    Adds a reference to a classpath defined elsewhere.
    Parameters:
      `r` - the classpath reference

  - ### createConfiguration

    public CompilerConfiguration createConfiguration()
    Returns the mutable compiler configuration used by this task.
    Returns:
      the compiler configuration

  - ### validate

    protected void validate() throws org.apache.tools.ant.BuildException
    Validates the task configuration before compilation starts.
    Throws:
      `org.apache.tools.ant.BuildException` - if required attributes are missing or invalid

  - ### createClassLoader

    protected GroovyClassLoader createClassLoader()
    Creates a class loader for the current compiler configuration and classpath.
    Returns:
      the class loader to use during compilation

  - ### handleException

    protected void handleException(Exception e) throws org.apache.tools.ant.BuildException
    Converts a compilation failure into the Ant task's configured error handling.
    Parameters:
      `e` - the exception raised by compilation
    Throws:
      `org.apache.tools.ant.BuildException` - if failures should abort the build

  - ### execute

    public void execute() throws org.apache.tools.ant.BuildException
    Validates the task and delegates to `compile()`.
    Overrides:
      `execute` in class `org.apache.tools.ant.Task`
    Throws:
      `org.apache.tools.ant.BuildException` - if validation fails or compilation fails fatally

  - ### compile

    protected abstract void compile() throws Exception
    Performs the concrete compilation work for the task.
    Throws:
      `Exception` - if compilation fails