org.codehaus.groovy.ant
Class Groovyc

Compiles Groovy source files. This task can take the following arguments:

Of these arguments, the srcdir and destdir are required.

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.

Based heavily on the Javac implementation in Ant.

author:
James Strachan
author:
Hein Meling
author:
Russel Winder
version:
$Revision: 10601 $

Field Summary
 Path compileClasspath
           
 def compileList
           
 Path compileSourcepath
           
 CompilerConfiguration configuration
           
 File destDir
           
 String encoding
           
 String errorProperty
           
 boolean failOnError
           
 boolean fork
           
 boolean includeAntRuntime
           
 boolean includeDestClasses
           
 boolean includeJavaRuntime
           
 Javac javac
           
 boolean jointCompilation
           
 boolean listFiles
           
 LoggingHelper log
           
 String memoryInitialSize
           
 String memoryMaximumSize
           
 Path src
           
 boolean taskSuccess
           
 String updatedProperty
           
 boolean verbose
           
 
Constructor Summary
Groovyc()
           
 
Method Summary
void addConfiguredJavac(Javac javac)
           Add the configured nested javac task if present to initiate joint compilation.
void addToCompileList(def newFiles)
          
GroovyClassLoader buildClassLoaderFor()
          
void checkParameters()
          
void compile()
          
Path createClasspath()
           Adds a path to the classpath.
Path createSourcepath()
           Adds a path to sourcepath.
Path createSrc()
           Adds a path for source compilation.
File createTempDir()
          
def evalCompilerFlags(Project project, def args)
          
void execute()
           Executes the task.
Path getClasspath()
           Gets the classpath to be used for this compilation.
File getDestdir()
           Gets the destination directory into which the java source files should be compiled.
String getEncoding()
           Returns the encoding to be used when creating files.
boolean getFailonerror()
           Gets the failonerror flag.
def getFileList()
           Gets the list of files to be compiled.
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 getListfiles()
           Get the listfiles flag.
String getMemoryInitialSize()
           Gets the memoryInitialSize flag.
String getMemoryMaximumSize()
           Gets the memoryMaximumSize flag.
Path getSourcepath()
           Gets the sourcepath to be used for this compilation.
Path getSrcdir()
           Gets the source dirs to find the source java files.
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.
static void main(def args)
           Provide an entry point for use by the java task.
CompilationUnit makeCompileUnit()
          
Path recreateSrc()
           Recreate src.
void resetFileLists()
           Clear the list of files to be compiled and copied..
void scanDir(File srcDir, File destDir, def files)
           Scans the directory looking for source files to be compiled.
void setClasspath(Path classpath)
           Set the classpath to be used for this compilation.
void setClasspathRef(Reference r)
           Adds a reference to a classpath defined elsewhere.
void setDestdir(File destDir)
           Set the destination directory into which the Java source files should be compiled.
void setEncoding(String encoding)
           Sets the file encoding for generated files.
void setErrorProperty(String errorProperty)
           The property to set on compliation failure.
void setFailonerror(boolean fail)
           Indicates whether the build will continue even if there are compilation errors; defaults to true.
void setFork(boolean f)
           If true forks the Groovy compiler.
void setIncludeDestClasses(boolean includeDestClasses)
           This property controls whether to include the destination classes directory in the classpath given to the compiler.
void setIncludeantruntime(boolean include)
           If true, includes Ant's own classpath in the classpath.
void setIncludejavaruntime(boolean include)
           If true, includes the Java runtime libraries in the classpath.
void setListfiles(boolean list)
           If true, list the source files being handed off to the compiler.
void setMemoryInitialSize(String memoryInitialSize)
           The initial size of the memory for the underlying VM if javac is run externally; ignored otherwise.
void setMemoryMaximumSize(String memoryMaximumSize)
           The maximum size of the memory for the underlying VM if javac is run externally; ignored otherwise.
void setProceed(boolean proceed)
          
void setSourcepath(Path sourcepath)
           Set the sourcepath to be used for this compilation.
void setSourcepathRef(Reference r)
           Adds a reference to a source path defined elsewhere.
void setSrcdir(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 setUpdatedProperty(String updatedProperty)
           The property to set on compliation success.
void setVerbose(boolean verbose)
           Enable verbose compiling which will display which files are being compiled
 

Constructor Detail

Groovyc

public Groovyc()


Method Detail

addConfiguredJavac

public void addConfiguredJavac(Javac javac)
Add the configured nested javac task if present to initiate joint compilation.


addToCompileList

void addToCompileList(def newFiles)


buildClassLoaderFor

GroovyClassLoader buildClassLoaderFor()


checkParameters

void checkParameters()


compile

void compile()


createClasspath

public Path createClasspath()
Adds a path to the classpath.
return:
a class path to be configured


createSourcepath

public Path createSourcepath()
Adds a path to sourcepath.
return:
a sourcepath to be configured


createSrc

public Path createSrc()
Adds a path for source compilation.
return:
a nested src element.


createTempDir

File createTempDir()


evalCompilerFlags

def evalCompilerFlags(Project project, def args)


execute

public void execute()
Executes the task.
exception:
BuildException if an error occurs


getClasspath

public Path getClasspath()
Gets the classpath to be used for this compilation.
return:
the class path


getDestdir

public File getDestdir()
Gets the destination directory into which the java source files should be compiled.
return:
the destination directory


getEncoding

public String getEncoding()
Returns the encoding to be used when creating files.
return:
the file encoding to use


getFailonerror

public boolean getFailonerror()
Gets the failonerror flag.
return:
the failonerror flag


getFileList

public def getFileList()
Gets the list of files to be compiled.
return:
the list of files as an array


getIncludeantruntime

public boolean getIncludeantruntime()
Gets whether or not the ant classpath is to be included in the classpath.
return:
whether or not the ant classpath is to be included in the classpath


getIncludejavaruntime

public boolean getIncludejavaruntime()
Gets whether or not the java runtime should be included in this task's classpath.
return:
the includejavaruntime attribute


getListfiles

public boolean getListfiles()
Get the listfiles flag.
return:
the listfiles flag


getMemoryInitialSize

public String getMemoryInitialSize()
Gets the memoryInitialSize flag.
return:
the memoryInitialSize flag


getMemoryMaximumSize

public String getMemoryMaximumSize()
Gets the memoryMaximumSize flag.
return:
the memoryMaximumSize flag


getSourcepath

public Path getSourcepath()
Gets the sourcepath to be used for this compilation.
return:
the source path


getSrcdir

public Path getSrcdir()
Gets the source dirs to find the source java files.
return:
the source directorys as a path


getTaskSuccess

public boolean getTaskSuccess()
Get the result of the groovyc task (success or failure).
return:
true if compilation succeeded, or
was not neccessary, false if the compilation failed.


getVerbose

public boolean getVerbose()
Gets the verbose flag.
return:
the verbose flag


isIncludeDestClasses

public boolean isIncludeDestClasses()
Get the value of the includeDestClasses property.
return:
the value.


main

public static void main(def args)
Provide an entry point for use by the java task. Also used for forking. FIXME: the includes and excludes are not handled -- there is no command line option for them.


makeCompileUnit

CompilationUnit makeCompileUnit()


recreateSrc

Path recreateSrc()
Recreate src.
return:
a nested src element.


resetFileLists

void resetFileLists()
Clear the list of files to be compiled and copied..


scanDir

void scanDir(File srcDir, File destDir, def files)
Scans the directory looking for source files to be compiled. The results are returned in the class variable compileList
param:
srcDir The source directory
param:
destDir The destination directory
param:
files An array of filenames


setClasspath

public void setClasspath(Path classpath)
Set the classpath to be used for this compilation.
param:
classpath an Ant Path object containing the compilation classpath.


setClasspathRef

public void setClasspathRef(Reference r)
Adds a reference to a classpath defined elsewhere.
param:
r a reference to a classpath


setDestdir

public void setDestdir(File destDir)
Set the destination directory into which the Java source files should be compiled.
param:
destDir the destination director


setEncoding

public void setEncoding(String encoding)
Sets the file encoding for generated files.
param:
encoding the file encoding to be used


setErrorProperty

public void setErrorProperty(String errorProperty)
The property to set on compliation failure. This property will be set if the compilation fails.
param:
errorProperty the property name to use.


setFailonerror

public void setFailonerror(boolean fail)
Indicates whether the build will continue even if there are compilation errors; defaults to true.
param:
fail if true halt the build on failure


setFork

public void setFork(boolean f)
If true forks the Groovy compiler.
param:
f "true|false|on|off|yes|no"


setIncludeDestClasses

public void setIncludeDestClasses(boolean includeDestClasses)
This property controls whether to include the destination classes directory in the classpath given to the compiler. The default value is "true".
param:
includeDestClasses the value to use.


setIncludeantruntime

public void setIncludeantruntime(boolean include)
If true, includes Ant's own classpath in the classpath.
param:
include if true, includes Ant's own classpath in the classpath


setIncludejavaruntime

public void setIncludejavaruntime(boolean include)
If true, includes the Java runtime libraries in the classpath.
param:
include if true, includes the Java runtime libraries in the classpath


setListfiles

public void setListfiles(boolean list)
If true, list the source files being handed off to the compiler.
param:
list if true list the source files


setMemoryInitialSize

public void setMemoryInitialSize(String memoryInitialSize)
The initial size of the memory for the underlying VM if javac is run externally; ignored otherwise. Defaults to the standard VM memory setting. (Examples: 83886080, 81920k, or 80m)
param:
memoryInitialSize string to pass to VM


setMemoryMaximumSize

public void setMemoryMaximumSize(String memoryMaximumSize)
The maximum size of the memory for the underlying VM if javac is run externally; ignored otherwise. Defaults to the standard VM memory setting. (Examples: 83886080, 81920k, or 80m)
param:
memoryMaximumSize string to pass to VM


setProceed

public void setProceed(boolean proceed)
param:
proceed inverse of failonerror


setSourcepath

public void setSourcepath(Path sourcepath)
Set the sourcepath to be used for this compilation.
param:
sourcepath the source path


setSourcepathRef

public void setSourcepathRef(Reference r)
Adds a reference to a source path defined elsewhere.
param:
r a reference to a source path


setSrcdir

public void setSrcdir(Path srcDir)
Set the source directories to find the source Java files.
param:
srcDir the source directories as a path


setStacktrace

public void setStacktrace(boolean stacktrace)
Enable compiler to report stack trace information if a problem occurs during compilation.


setUpdatedProperty

public void setUpdatedProperty(String updatedProperty)
The property to set on compliation success. This property will not be set if the compilation fails, or if there are no files to compile.
param:
updatedProperty the property name to use.


setVerbose

public void setVerbose(boolean verbose)
Enable verbose compiling which will display which files are being compiled