public class Groovyc
extends org.apache.tools.ant.taskdefs.MatchingTask
Typically involves using Ant from the command-line and an Ant build file such as:
 <?xml version="1.0"?>
 <project name="MyGroovyBuild" default="compile">
   <property name="groovy.home" value="/Path/To/Groovy"/>
   <property name="groovy.version" value="X.Y.Z"/>
   <path id="groovy.classpath">
     <fileset dir="${groovy.home}/embeddable">
       <include name="groovy-all-${groovy.version}.jar" />
     </fileset>
   </path>
   <taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc" classpathref="groovy.classpath"/>
   <target name="compile" description="compile groovy sources">
     <groovyc srcdir="src" listfiles="true" classpathref="groovy.classpath"/>
   </target>
 </project>
 
 This task can take the following arguments:
When this task executes, it will recursively scan srcdir and destdir looking for Groovy source files to compile. This task makes its compile decision based on timestamp.
A more elaborate build file showing joint compilation:
 <?xml version="1.0"?>
 <project name="MyJointBuild" default="compile">
   <property name="groovy.home" value="/Path/To/Groovy"/>
   <property name="groovy.version" value="X.Y.Z"/>
   <path id="groovy.classpath">
     <fileset dir="${groovy.home}/embeddable">
       <include name="groovy-all-${groovy.version}.jar" />
     </fileset>
   </path>
   <target name="clean" description="remove all built files">
     <delete dir="classes" />
   </target>
   <target name="compile" depends="init" description="compile java and groovy sources">
     <mkdir dir="classes" />
     <groovyc destdir="classes" srcdir="src" listfiles="true" keepStubs="true" stubdir="stubs">
       <javac debug="on" deprecation="true"/>
       <classpath>
         <fileset dir="classes"/>
         <path refid="groovy.classpath"/>
       </classpath>
     </groovyc>
   </target>
   <target name="init">
     <taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc" classpathref="groovy.classpath"/>
   </target>
 </project>
 
 Based on the implementation of the Javac task in Apache Ant.
 Can also be used from AntBuilder to allow the build file to be scripted in Groovy.
| Modifier and Type | Field and Description | 
|---|---|
| protected java.io.File[] | compileList | 
| protected CompilerConfiguration | configuration | 
| protected boolean | failOnError | 
| protected boolean | listFiles | 
| Constructor and Description | 
|---|
| Groovyc() | 
| Modifier and Type | Method and Description | 
|---|---|
| void | addConfiguredJavac(org.apache.tools.ant.taskdefs.Javac javac)Add the configured nested javac task if present to initiate joint compilation. | 
| protected void | addToCompileList(java.io.File[] newFiles) | 
| protected GroovyClassLoader | buildClassLoaderFor() | 
| protected void | checkParameters() | 
| protected void | compile() | 
| org.apache.tools.ant.types.Path | createClasspath()Adds a path to the classpath. | 
| org.apache.tools.ant.types.Path | createSourcepath()Adds a path to sourcepath. | 
| org.apache.tools.ant.types.Path | createSrc()Adds a path for source compilation. | 
| void | execute()Executes the task. | 
| org.apache.tools.ant.types.Path | getClasspath()Gets the classpath to be used for this compilation. | 
| java.lang.String | getConfigscript()Get the configuration file used to customize the compilation configuration. | 
| java.io.File | getDestdir()Gets the destination directory into which the java source files
 should be compiled. | 
| java.lang.String | getEncoding()Returns the encoding to be used when creating files. | 
| java.lang.String | getExecutable()The value of the executable attribute, if any. | 
| boolean | getFailonerror()Gets the failonerror flag. | 
| java.io.File[] | getFileList()Gets the list of files to be compiled. | 
| boolean | getForceLookupUnnamedFiles()Gets the forceLookupUnnamedFiles flag. | 
| boolean | getIncludeantruntime()Gets whether or not the ant classpath is to be included in the classpath. | 
| boolean | getIncludejavaruntime()Gets whether or not the java runtime should be included in this
 task's classpath. | 
| boolean | getIndy()Get the value of the indy flag. | 
| boolean | getKeepStubs()Gets the keepStubs flag. | 
| boolean | getListfiles()Get the listfiles flag. | 
| java.lang.String | getMemoryInitialSize()Gets the memoryInitialSize flag. | 
| java.lang.String | getMemoryMaximumSize()Gets the memoryMaximumSize flag. | 
| boolean | getParameters()Returns true if parameter metadata generation has been enabled. | 
| java.lang.String | getScriptBaseClass()Get the base script class name for the scripts (must derive from Script) | 
| java.lang.String | getScriptExtension()Get the extension to use when searching for Groovy source files. | 
| org.apache.tools.ant.types.Path | getSourcepath()Gets the sourcepath to be used for this compilation. | 
| org.apache.tools.ant.types.Path | getSrcdir()Gets the source dirs to find the source java files. | 
| java.io.File | getStubdir()Gets the stub directory into which the Java source stub
 files should be generated | 
| java.lang.String | getTargetBytecode()Retrieves the compiler bytecode compatibility level. | 
| boolean | getTaskSuccess()Get the result of the groovyc task (success or failure). | 
| boolean | getVerbose()Gets the verbose flag. | 
| boolean | isIncludeDestClasses()Get the value of the includeDestClasses property. | 
| protected CompilationUnit | makeCompileUnit()Deprecated. 
 This method is not in use anymore. Use  makeCompileUnit(GroovyClassLoader)instead. | 
| protected CompilationUnit | makeCompileUnit(GroovyClassLoader loader) | 
| protected org.apache.tools.ant.types.Path | recreateSrc()Recreate src. | 
| protected void | resetFileLists()Clear the list of files to be compiled and copied. | 
| protected void | scanDir(java.io.File srcDir,
       java.io.File destDir,
       java.lang.String[] files)Scans the directory looking for source files to be compiled. | 
| void | setClasspath(org.apache.tools.ant.types.Path classpath)Set the classpath to be used for this compilation. | 
| void | setClasspathRef(org.apache.tools.ant.types.Reference r)Adds a reference to a classpath defined elsewhere. | 
| void | setConfigscript(java.lang.String configscript)Set the configuration file used to customize the compilation configuration. | 
| void | setDestdir(java.io.File destDir)Set the destination directory into which the Java source
 files should be compiled. | 
| void | setEncoding(java.lang.String encoding)Sets the file encoding for generated files. | 
| void | setErrorProperty(java.lang.String errorProperty)The property to set on compilation failure. | 
| void | setExecutable(java.lang.String forkExecPath)Sets the name of the java executable to use when
 invoking the compiler in forked mode, ignored otherwise. | 
| void | setFailonerror(boolean fail)Indicates whether the build will continue
 even if there are compilation errors; defaults to true. | 
| void | setForceLookupUnnamedFiles(boolean forceLookupUnnamedFiles)Set the forceLookupUnnamedFiles flag. | 
| void | setFork(boolean f)If true forks the Groovy compiler. | 
| void | setIncludeantruntime(boolean include)If true, includes Ant's own classpath in the classpath. | 
| void | setIncludeDestClasses(boolean includeDestClasses)This property controls whether to include the
 destination classes directory in the classpath
 given to the compiler. | 
| void | setIncludejavaruntime(boolean include)If true, includes the Java runtime libraries in the classpath. | 
| void | setIndy(boolean useIndy)Set the indy flag. | 
| void | setJavaHome(java.io.File home)The JDK Home to use when forked. | 
| void | setKeepStubs(boolean keepStubs)Set the keepStubs flag. | 
| void | setListfiles(boolean list)If true, list the source files being handed off to the compiler. | 
| void | setMemoryInitialSize(java.lang.String memoryInitialSize)The initial size of the memory for the underlying VM
 if javac is run externally; ignored otherwise. | 
| void | setMemoryMaximumSize(java.lang.String memoryMaximumSize)The maximum size of the memory for the underlying VM
 if javac is run externally; ignored otherwise. | 
| void | setParameters(boolean parameters)If true, generates metadata for reflection on method parameter names (jdk8+ only). | 
| void | setProceed(boolean proceed) | 
| void | setScriptBaseClass(java.lang.String scriptBaseClass)Set the base script class name for the scripts (must derive from Script) | 
| void | setScriptExtension(java.lang.String scriptExtension)Set the extension to use when searching for Groovy source files. | 
| void | setSourcepath(org.apache.tools.ant.types.Path sourcepath)Set the sourcepath to be used for this compilation. | 
| void | setSourcepathRef(org.apache.tools.ant.types.Reference r)Adds a reference to a source path defined elsewhere. | 
| void | setSrcdir(org.apache.tools.ant.types.Path srcDir)Set the source directories to find the source Java files. | 
| void | setStacktrace(boolean stacktrace)Enable compiler to report stack trace information if a problem occurs
 during compilation. | 
| void | setStubdir(java.io.File stubDir)Set the stub directory into which the Java source stub
 files should be generated. | 
| void | setTargetBytecode(java.lang.String version)Sets the bytecode compatibility level. | 
| void | setUpdatedProperty(java.lang.String updatedProperty)The property to set on compilation success. | 
| void | setVerbose(boolean verbose)Enable verbose compiling which will display which files
 are being compiled. | 
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, XsetItemsbindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskTypeprotected boolean failOnError
protected boolean listFiles
protected java.io.File[] compileList
protected CompilerConfiguration configuration
public org.apache.tools.ant.types.Path createSrc()
protected org.apache.tools.ant.types.Path recreateSrc()
public void setSrcdir(org.apache.tools.ant.types.Path srcDir)
srcDir - the source directories as a pathpublic org.apache.tools.ant.types.Path getSrcdir()
public void setScriptExtension(java.lang.String scriptExtension)
scriptExtension - the extension of Groovy source filespublic java.lang.String getScriptExtension()
public void setTargetBytecode(java.lang.String version)
CompilerConfiguration.ALLOWED_JDKS.version - the bytecode compatibility levelpublic java.lang.String getTargetBytecode()
CompilerConfiguration.ALLOWED_JDKS.public void setDestdir(java.io.File destDir)
destDir - the destination directorpublic java.io.File getDestdir()
public void setSourcepath(org.apache.tools.ant.types.Path sourcepath)
sourcepath - the source pathpublic org.apache.tools.ant.types.Path getSourcepath()
public org.apache.tools.ant.types.Path createSourcepath()
public void setSourcepathRef(org.apache.tools.ant.types.Reference r)
r - a reference to a source pathpublic void setClasspath(org.apache.tools.ant.types.Path classpath)
classpath - an Ant Path object containing the compilation classpath.public org.apache.tools.ant.types.Path getClasspath()
public org.apache.tools.ant.types.Path createClasspath()
public void setClasspathRef(org.apache.tools.ant.types.Reference r)
r - a reference to a classpathpublic void setListfiles(boolean list)
list - if true list the source filespublic boolean getListfiles()
public void setFailonerror(boolean fail)
fail - if true halt the build on failurepublic void setProceed(boolean proceed)
proceed - inverse of failonerrorpublic boolean getFailonerror()
public void setMemoryInitialSize(java.lang.String memoryInitialSize)
memoryInitialSize - string to pass to VMpublic java.lang.String getMemoryInitialSize()
public void setMemoryMaximumSize(java.lang.String memoryMaximumSize)
memoryMaximumSize - string to pass to VMpublic java.lang.String getMemoryMaximumSize()
public void setEncoding(java.lang.String encoding)
encoding - the file encoding to be usedpublic java.lang.String getEncoding()
public void setVerbose(boolean verbose)
public boolean getVerbose()
public void setIncludeantruntime(boolean include)
include - if true, includes Ant's own classpath in the classpathpublic boolean getIncludeantruntime()
public void setIncludejavaruntime(boolean include)
include - if true, includes the Java runtime libraries in the classpathpublic boolean getIncludejavaruntime()
public void setFork(boolean f)
f - "true|false|on|off|yes|no"public void setJavaHome(java.io.File home)
home - the java.home value to use, default is the current JDK's homepublic void setExecutable(java.lang.String forkExecPath)
forkExecPath - the name of the executablepublic java.lang.String getExecutable()
public void setUpdatedProperty(java.lang.String updatedProperty)
updatedProperty - the property name to use.public void setErrorProperty(java.lang.String errorProperty)
errorProperty - the property name to use.public void setIncludeDestClasses(boolean includeDestClasses)
includeDestClasses - the value to use.public boolean isIncludeDestClasses()
public boolean getTaskSuccess()
public void addConfiguredJavac(org.apache.tools.ant.taskdefs.Javac javac)
public void setStacktrace(boolean stacktrace)
public void setIndy(boolean useIndy)
useIndy - the indy flagpublic boolean getIndy()
public void setScriptBaseClass(java.lang.String scriptBaseClass)
scriptBaseClass - Base class name for scripts (must derive from Script)public java.lang.String getScriptBaseClass()
public java.lang.String getConfigscript()
public void setConfigscript(java.lang.String configscript)
configscript - a path to a configuration scriptpublic void setStubdir(java.io.File stubDir)
stubDir - the stub directorypublic java.io.File getStubdir()
public void setKeepStubs(boolean keepStubs)
keepStubs - should stubs be retainedpublic boolean getKeepStubs()
public void setForceLookupUnnamedFiles(boolean forceLookupUnnamedFiles)
 The Groovyc Ant task is frequently used in the context of a build system
 that knows the complete list of source files to be compiled. In such a
 context, it is wasteful for the Groovy compiler to go searching the
 classpath when looking for source files and hence by default the
 Groovyc Ant task calls the compiler in a special mode with such searching
 turned off. If you wish the compiler to search for source files then
 you need to set this flag to true.
forceLookupUnnamedFiles - should unnamed source files be searched for on the classpathpublic boolean getForceLookupUnnamedFiles()
public void setParameters(boolean parameters)
parameters - set to true to generate metadata.public boolean getParameters()
public void execute()
             throws org.apache.tools.ant.BuildException
execute in class org.apache.tools.ant.Taskorg.apache.tools.ant.BuildException - if an error occursprotected void resetFileLists()
protected void scanDir(java.io.File srcDir,
                       java.io.File destDir,
                       java.lang.String[] files)
srcDir - The source directorydestDir - The destination directoryfiles - An array of filenamesprotected void addToCompileList(java.io.File[] newFiles)
public java.io.File[] getFileList()
protected void checkParameters()
                        throws org.apache.tools.ant.BuildException
org.apache.tools.ant.BuildExceptionprotected void compile()
@Deprecated protected CompilationUnit makeCompileUnit()
makeCompileUnit(GroovyClassLoader) instead.protected CompilationUnit makeCompileUnit(GroovyClassLoader loader)
protected GroovyClassLoader buildClassLoaderFor()