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
FieldsModifier and TypeFieldDescriptionprotected org.apache.tools.ant.types.PathCompilation classpath.protected CompilerConfigurationCompiler configuration shared with the concrete task implementation.protected FileDestination directory for generated output.protected booleanWhether task failures should stop the Ant build.protected final LoggingHelperLogger used by subclasses to report task progress.protected org.apache.tools.ant.types.PathSource roots to scan for compilation inputs.Fields inherited from class org.apache.tools.ant.taskdefs.MatchingTask
filesetFields inherited from class org.apache.tools.ant.Task
target, taskName, taskType, wrapperFields inherited from class org.apache.tools.ant.ProjectComponent
description, location, project -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidcompile()Performs the concrete compilation work for the task.protected GroovyClassLoaderCreates a class loader for the current compiler configuration and classpath.org.apache.tools.ant.types.PathCreates a nested<classpath>path element.Returns the mutable compiler configuration used by this task.org.apache.tools.ant.types.PathCreates a nested<src>path element.voidexecute()Validates the task and delegates tocompile().org.apache.tools.ant.types.PathReturns the configured compilation classpath.booleanIndicates whether compilation errors fail the Ant build.org.apache.tools.ant.types.PathReturns the configured source roots.protected voidConverts a compilation failure into the Ant task's configured error handling.voidsetClasspath(org.apache.tools.ant.types.Path path) Adds entries to the compilation classpath.voidsetClasspathRef(org.apache.tools.ant.types.Reference r) Adds a reference to a classpath defined elsewhere.voidsetDestdir(File dir) Sets the output directory for generated classes or stubs.voidsetFailonerror(boolean fail) Controls whether compilation errors should fail the Ant build.voidsetSrcdir(org.apache.tools.ant.types.Path dir) Adds source roots to the task.protected voidvalidate()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, XsetItemsMethods 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, setTaskTypeMethods inherited from class org.apache.tools.ant.ProjectComponent
clone, getDescription, getLocation, getProject, setDescription, setLocation
-
Field Details
-
log
Logger used by subclasses to report task progress. -
src
protected org.apache.tools.ant.types.Path srcSource roots to scan for compilation inputs. -
destdir
Destination directory for generated output. -
classpath
protected org.apache.tools.ant.types.Path classpathCompilation classpath. -
config
Compiler configuration shared with the concrete task implementation. -
failOnError
protected boolean failOnErrorWhether 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-trueto fail the build on compilation errors
-
getFailonerror
public boolean getFailonerror()Indicates whether compilation errors fail the Ant build.- Returns:
trueif 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
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
Returns the mutable compiler configuration used by this task.- Returns:
- the compiler configuration
-
validate
protected void validate() throws org.apache.tools.ant.BuildExceptionValidates the task configuration before compilation starts.- Throws:
org.apache.tools.ant.BuildException- if required attributes are missing or invalid
-
createClassLoader
Creates a class loader for the current compiler configuration and classpath.- Returns:
- the class loader to use during compilation
-
handleException
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.BuildExceptionValidates the task and delegates tocompile().- Overrides:
executein classorg.apache.tools.ant.Task- Throws:
org.apache.tools.ant.BuildException- if validation fails or compilation fails fatally
-
compile
Performs the concrete compilation work for the task.- Throws:
Exception- if compilation fails
-