org.codehaus.groovy.ant
Class Groovyc

java.lang.Object
  extended by org.apache.tools.ant.ProjectComponent
      extended by org.apache.tools.ant.Task
          extended by org.apache.tools.ant.taskdefs.MatchingTask
              extended by org.codehaus.groovy.ant.Groovyc
All Implemented Interfaces:
Cloneable, org.apache.tools.ant.types.selectors.SelectorContainer

public class Groovyc
extends org.apache.tools.ant.taskdefs.MatchingTask

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

Of these arguments, the sourcedir and destdir are required.

When this task executes, it will recursively scan the sourcedir 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

Version:
$Revision: 2690 $
Author:
James Strachan, Hein Meling

Field Summary
protected  File[] compileList
           
protected  boolean failOnError
           
protected  boolean listFiles
           
 
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
Groovyc()
           
 
Method Summary
protected  void checkParameters()
           
protected  void compile()
           
 org.apache.tools.ant.types.Path createClasspath()
          Adds a path to the classpath.
 String createEncoding()
           
 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.
 File getDestdir()
          Gets the destination directory into which the java source files should be compiled.
 String getEncoding()
           
 boolean getFailonerror()
          Gets the failonerror flag.
 File[] getFileList()
          Gets the list of files to be compiled.
 boolean getListfiles()
          Get the listfiles flag.
 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.
static void main(String[] args)
           
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(File srcDir, File destDir, 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 setDestdir(File destDir)
          Set the destination directory into which the Java source files should be compiled.
 void setEncoding(String encoding)
           
 void setFailonerror(boolean fail)
          Indicates whether the build will continue even if there are compilation errors; defaults to true.
 void setListfiles(boolean list)
          If true, list the source files being handed off to the compiler.
 void setProceed(boolean proceed)
           
 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 setVerbose(boolean verbose)
          Enable verbose compiling which will display which files are being compiled
 
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 Detail

failOnError

protected boolean failOnError

listFiles

protected boolean listFiles

compileList

protected File[] compileList
Constructor Detail

Groovyc

public Groovyc()
Method Detail

main

public static void main(String[] args)

createSrc

public org.apache.tools.ant.types.Path createSrc()
Adds a path for source compilation.

Returns:
a nested src element.

recreateSrc

protected org.apache.tools.ant.types.Path recreateSrc()
Recreate src.

Returns:
a nested src element.

setSrcdir

public void setSrcdir(org.apache.tools.ant.types.Path srcDir)
Set the source directories to find the source Java files.

Parameters:
srcDir - the source directories as a path

getSrcdir

public org.apache.tools.ant.types.Path getSrcdir()
Gets the source dirs to find the source java files.

Returns:
the source directorys as a path

setDestdir

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

Parameters:
destDir - the destination director

setVerbose

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

Parameters:
verbose -

setStacktrace

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

Parameters:
stacktrace -

getDestdir

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

Returns:
the destination directory

setSourcepath

public void setSourcepath(org.apache.tools.ant.types.Path sourcepath)
Set the sourcepath to be used for this compilation.

Parameters:
sourcepath - the source path

getSourcepath

public org.apache.tools.ant.types.Path getSourcepath()
Gets the sourcepath to be used for this compilation.

Returns:
the source path

createSourcepath

public org.apache.tools.ant.types.Path createSourcepath()
Adds a path to sourcepath.

Returns:
a sourcepath to be configured

setSourcepathRef

public void setSourcepathRef(org.apache.tools.ant.types.Reference r)
Adds a reference to a source path defined elsewhere.

Parameters:
r - a reference to a source path

setClasspath

public void setClasspath(org.apache.tools.ant.types.Path classpath)
Set the classpath to be used for this compilation.

Parameters:
classpath - an Ant Path object containing the compilation classpath.

getClasspath

public org.apache.tools.ant.types.Path getClasspath()
Gets the classpath to be used for this compilation.

Returns:
the class path

createClasspath

public org.apache.tools.ant.types.Path createClasspath()
Adds a path to the classpath.

Returns:
a class path to be configured

setClasspathRef

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

Parameters:
r - a reference to a classpath

createEncoding

public String createEncoding()

setEncoding

public void setEncoding(String encoding)

getEncoding

public String getEncoding()

setListfiles

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

Parameters:
list - if true list the source files

getListfiles

public boolean getListfiles()
Get the listfiles flag.

Returns:
the listfiles flag

setFailonerror

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

Parameters:
fail - if true halt the build on failure

setProceed

public void setProceed(boolean proceed)
Parameters:
proceed - inverse of failoferror

getFailonerror

public boolean getFailonerror()
Gets the failonerror flag.

Returns:
the failonerror flag

execute

public void execute()
             throws org.apache.tools.ant.BuildException
Executes the task.

Overrides:
execute in class org.apache.tools.ant.Task
Throws:
org.apache.tools.ant.BuildException - if an error occurs

resetFileLists

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


scanDir

protected void scanDir(File srcDir,
                       File destDir,
                       String[] files)
Scans the directory looking for source files to be compiled. The results are returned in the class variable compileList

Parameters:
srcDir - The source directory
destDir - The destination directory
files - An array of filenames

getFileList

public File[] getFileList()
Gets the list of files to be compiled.

Returns:
the list of files as an array

checkParameters

protected void checkParameters()
                        throws org.apache.tools.ant.BuildException
Throws:
org.apache.tools.ant.BuildException

compile

protected void compile()


Copyright © 2003-2010 The Codehaus. All Rights Reserved.