org.codehaus.groovy.ant
Class Groovy

Executes a series of Groovy statements.

Statements can either be read in from a text file using the src attribute or from between the enclosing groovy tags.

version:
$Id: Groovy.java 13044 2008-07-14 05:28:13Z paulk $

Field Summary
 String PREFIX
           
 String SUFFIX
           
 boolean append
           
 Path classpath
           
 Commandline cmdline
           
 String command
           
 CompilerConfiguration configuration
           
 Vector filesets
           
 boolean fork
           
 boolean includeAntRuntime
           
 LoggingHelper log
           
 File output
           
 File srcFile
           
 boolean useGroovyShell
           
 
Constructor Summary
Groovy()
           
 
Method Summary
void addClassPathes(GroovyClassLoader classLoader)
           Adds the class pathes (if any)
void addFileset(FileSet set)
           Adds a set of files (nested fileset attribute).
void addText(String txt)
           Set an inline command to execute.
String computeScriptName()
           Try to build a script name for the script of the groovy task to have an helpful value in stack traces in case of exception
def createArg()
          
Path createClasspath()
           Returns a new path element that can be configured.
void createClasspathParts()
          
void createNewArgs(String txt)
          
void execGroovy(String txt, PrintStream out)
           Exec the statement.
void execute()
           Load the file and then execute it
Path getClasspath()
           Gets the classpath.
static String getText(BufferedReader reader)
          
static void main(def args)
          
void parseAndRunScript(GroovyShell shell, String txt, Object mavenPom, String scriptName, File scriptFile, AntBuilder builder)
          
void printResults(PrintStream out)
           print any results in the statement.
void processError(Exception e)
          
void runStatements(Reader reader, PrintStream out)
           Read in lines and execute them.
void setAppend(boolean append)
           Whether output should be appended to or overwrite an existing file.
void setClasspath(Path classpath)
           Sets the classpath for loading.
void setClasspathRef(Reference ref)
           Set the classpath for loading using the classpath reference.
void setFork(boolean fork)
           files to load
void setIncludeAntRuntime(boolean includeAntRuntime)
           Should the system classpath be included on the classpath when forking.
void setOutput(File output)
           Set the output file; optional, defaults to the Ant log.
void setSrc(File srcFile)
           Set the name of the file to be run.
void setStacktrace(boolean stacktrace)
           Enable compiler to report stack trace information if a problem occurs during compilation.
void setUseGroovyShell(boolean useGroovyShell)
           Should a new GroovyShell be used when forking.
 

Constructor Detail

Groovy

Groovy()


Method Detail

addClassPathes

void addClassPathes(GroovyClassLoader classLoader)
Adds the class pathes (if any)
param:
classLoader the classloader to configure


addFileset

public void addFileset(FileSet set)
Adds a set of files (nested fileset attribute).
param:
set the fileset representing source files


addText

public void addText(String txt)
Set an inline command to execute. NB: Properties are not expanded in this text.
param:
txt the inline groovy ommands to execute


computeScriptName

String computeScriptName()
Try to build a script name for the script of the groovy task to have an helpful value in stack traces in case of exception
return:
the name to use when compiling the script


createArg

public def createArg()


createClasspath

public Path createClasspath()
Returns a new path element that can be configured. Gets called for instance by Ant when it encounters a nested <classpath> element.
return:
the resulting created path


createClasspathParts

void createClasspathParts()


createNewArgs

void createNewArgs(String txt)


execGroovy

void execGroovy(String txt, PrintStream out)
Exec the statement.
param:
txt the groovy source to exec
param:
out not used?


execute

public void execute()
Load the file and then execute it


getClasspath

public Path getClasspath()
Gets the classpath.
return:
Returns a Path


getText

static String getText(BufferedReader reader)


main

public static void main(def args)


parseAndRunScript

void parseAndRunScript(GroovyShell shell, String txt, Object mavenPom, String scriptName, File scriptFile, AntBuilder builder)


printResults

void printResults(PrintStream out)
print any results in the statement.
param:
out the output PrintStream to print to


processError

void processError(Exception e)


runStatements

void runStatements(Reader reader, PrintStream out)
Read in lines and execute them.
param:
reader the reader from which to get the groovy source to exec
param:
out the outputstream to use
throws:
java.io.IOException if something goes wrong


setAppend

public void setAppend(boolean append)
Whether output should be appended to or overwrite an existing file. Defaults to false.
param:
append set to true to append


setClasspath

public void setClasspath(Path classpath)
Sets the classpath for loading.
param:
classpath The classpath to set


setClasspathRef

public void setClasspathRef(Reference ref)
Set the classpath for loading using the classpath reference.
param:
ref the refid to use


setFork

public void setFork(boolean fork)
files to load


setIncludeAntRuntime

public void setIncludeAntRuntime(boolean includeAntRuntime)
Should the system classpath be included on the classpath when forking. Defaults to true.
param:
includeAntRuntime true if the system classpath should be on the classpath


setOutput

public void setOutput(File output)
Set the output file; optional, defaults to the Ant log.
param:
output the output file


setSrc

public void setSrc(File srcFile)
Set the name of the file to be run. The folder of the file is automatically added to the classpath. Required unless statements are enclosed in the build file
param:
srcFile the file containing the groovy script to execute


setStacktrace

public void setStacktrace(boolean stacktrace)
Enable compiler to report stack trace information if a problem occurs during compilation.
param:
stacktrace set to true to enable stacktrace reporting


setUseGroovyShell

public void setUseGroovyShell(boolean useGroovyShell)
Should a new GroovyShell be used when forking. Special variables won't be available but you don't need Ant in the classpath.
param:
useGroovyShell true if GroovyShell should be used to run the script directly