org.codehaus.groovy.ant
Class Groovy

java.lang.Object
  extended by org.apache.tools.ant.ProjectComponent
      extended by org.apache.tools.ant.Task
          extended by org.codehaus.groovy.ant.Groovy
All Implemented Interfaces:
Cloneable

public class Groovy
extends Task

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 11025 2008-03-10 03:17:40Z paulk $

Field Summary
 
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
Groovy()
           
 
Method Summary
protected  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.
 Commandline.Argument createArg()
           
 Path createClasspath()
          Returns a new path element that can be configured.
protected  void execGroovy(String txt, PrintStream out)
          Exec the statement.
 void execute()
          Load the file and then execute it
 Path getClasspath()
          Gets the classpath.
protected  void printResults(PrintStream out)
          print any results in the statement.
protected  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 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.
 
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, setProject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Groovy

public Groovy()
Method Detail

setStacktrace

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

Parameters:
stacktrace - set to true to enable stacktrace reporting

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


addText

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


addFileset

public void addFileset(FileSet set)
Adds a set of files (nested fileset attribute).


setOutput

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


setAppend

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

Parameters:
append - set to true to append

setClasspath

public void setClasspath(Path classpath)
Sets the classpath for loading.

Parameters:
classpath - The classpath to set

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.

Returns:
the resulting created path

setClasspathRef

public void setClasspathRef(Reference ref)
Set the classpath for loading using the classpath reference.

Parameters:
ref - the refid to use

getClasspath

public Path getClasspath()
Gets the classpath.

Returns:
Returns a Path

execute

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

Overrides:
execute in class Task
Throws:
BuildException

createArg

public Commandline.Argument createArg()

runStatements

protected void runStatements(Reader reader,
                             PrintStream out)
                      throws IOException
Read in lines and execute them.

Parameters:
reader - the reader from which to get the groovy source to exec
Throws:
IOException

execGroovy

protected void execGroovy(String txt,
                          PrintStream out)
Exec the statement.

Parameters:
txt - the groovy source to exec

addClassPathes

protected void addClassPathes(GroovyClassLoader classLoader)
Adds the class pathes (if any)

Parameters:
classLoader - the classloader to configure

printResults

protected void printResults(PrintStream out)
print any results in the statement.

Parameters:
out - the output PrintStream to print to

Copyright © 2003-2008 The Codehaus. All rights reserved.