Overview | Package | Class | Deprecated | Index | Help
| Groovy 1.7.10
| FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.codehaus.groovy.ant
[Java] Class Groovy

    java.lang.Object
      org.apache.tools.ant.ProjectComponent
          org.apache.tools.ant.Task
              org.apache.tools.ant.taskdefs.Java
                  org.codehaus.groovy.ant.Groovy

    public class Groovy
    extends Java

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 19652 2010-03-23 05:05:50Z paulk \$

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.
`def` | `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.
`static void` | `main(String[] args)`
`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` | `setContextClassLoader(boolean contextClassLoader)` Setting to true will cause the contextClassLoader to be set with the classLoader of the shell used to run the script.
`void` | `setFork(boolean fork)` Should the script be executed using a forked process.
`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.

Methods inherited from class Java
setError, setInput, execute, handleInput, setClassname, setClasspath, createClasspath, setClasspathRef, setDir, createBootclasspath, setFailonerror, setFork, setErrorProperty, createArg, createJvmarg, addSysproperty, executeJava, setSpawn, createPermissions, setJar, setArgs, setCloneVm, setResultProperty, setJvmargs, setJvm, addSyspropertyset, setOutput, setInputString, setLogError, setOutputproperty, setMaxmemory, setJVMVersion, addEnv, setNewenvironment, setAppend, setTimeout, addAssertions, addConfiguredRedirector, clearArgs, getCommandLine, getSysProperties, log, log, log, log, init, perform, maybeConfigure, setTaskType, setTaskName, setOwningTarget, getTaskName, getOwningTarget, getRuntimeConfigurableWrapper, setRuntimeConfigurableWrapper, reconfigure, getTaskType, bindToOwner, clone, getLocation, getDescription, setLocation, getProject, setDescription, setProject, wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll

Methods inherited from class Task
log, log, log, log, init, execute, perform, maybeConfigure, setTaskType, setTaskName, setOwningTarget, getTaskName, getOwningTarget, getRuntimeConfigurableWrapper, setRuntimeConfigurableWrapper, reconfigure, getTaskType, bindToOwner, clone, getLocation, getDescription, setLocation, getProject, setDescription, setProject, wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll

Methods inherited from class ProjectComponent
clone, log, log, getLocation, getDescription, setLocation, getProject, setDescription, setProject, wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll

Methods inherited from class Object
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll

Method Detail

### addClassPathes

    protected void addClassPathes(GroovyClassLoader classLoader)

  Adds the class pathes (if any)
  Parameters:
    `classLoader` - the classloader to configure

### addFileset

    public void addFileset(FileSet set)

  Adds a set of files (nested fileset attribute).
  Parameters:
    `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.
  Parameters:
    `txt` - the inline groovy ommands to execute

### 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.
  Returns:
    the resulting created path

### execGroovy

    protected void execGroovy(String txt, PrintStream out)

  Exec the statement.
  Parameters:
    `txt` - the groovy source to exec
    `out` - not used?

### execute

    public void execute()

  Load the file and then execute it

### getClasspath

    public Path getClasspath()

  Gets the classpath.
  Returns:
    Returns a Path

### main

    public static void main(String[] args)

### printResults

    protected void printResults(PrintStream out)

  print any results in the statement.
  Parameters:
    `out` - the output PrintStream to print to

### runStatements

    protected void runStatements(Reader reader, PrintStream out)

  Read in lines and execute them.
  throws:
    java.io.IOException if something goes wrong
  Parameters:
    `reader` - the reader from which to get the groovy source to exec
    `out` - the outputstream to use

### 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

### setClasspathRef

    public void setClasspathRef(Reference ref)

  Set the classpath for loading using the classpath reference.
  Parameters:
    `ref` - the refid to use

### setContextClassLoader

    public void setContextClassLoader(boolean contextClassLoader)

  Setting to true will cause the contextClassLoader to be set with the classLoader of the shell used to run the script. Not used if fork is true. Not allowed when running from Maven but in that case the context classLoader is set appropriately for Maven.
  Parameters:
    `contextClassLoader` - set to true to set the context classloader

### setFork

    public void setFork(boolean fork)

  Should the script be executed using a forked process. Defaults to false.
  Parameters:
    `fork` - true if the script should be executed in a forked process

### setIncludeAntRuntime

    public void setIncludeAntRuntime(boolean includeAntRuntime)

  Should the system classpath be included on the classpath when forking. Defaults to true.
  Parameters:
    `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.
  Parameters:
    `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
  Parameters:
    `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.
  Parameters:
    `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.
  Parameters:
    `useGroovyShell` - true if GroovyShell should be used to run the script directly

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