org.codehaus.groovy.ant
Class Groovy

java.lang.Object
  extended byorg.apache.tools.ant.ProjectComponent
      extended byorg.apache.tools.ant.Task
          extended byorg.codehaus.groovy.ant.Groovy

public class Groovy
extends org.apache.tools.ant.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.

Based heavily on SQLExec.java which is part of apache-ant http://cvs.apache.org/viewcvs.cgi/ant/src/main/org/apache/tools/ant/taskdefs/SQLExec.java?rev=MAIN Copyright 2000-2005 The Apache Software Foundation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.


Field Summary
 
Fields inherited from class org.apache.tools.ant.Task
description, location, target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
project
 
Constructor Summary
Groovy()
           
 
Method Summary
 void addFileset(org.apache.tools.ant.types.FileSet set)
          Adds a set of files (nested fileset attribute).
 void addText(String txt)
          Set an inline command to execute.
 org.apache.tools.ant.types.Path createClasspath()
          Add a path to the classpath for loading.
protected  void execGroovy(String txt, PrintStream out)
          Exec the statement.
 void execute()
          Load the file and then execute it
 org.apache.tools.ant.types.Path getClasspath()
          Gets the classpath.
protected static Hashtable getLoaderMap()
           
 String getUserId()
          Gets the userId.
 String getVersion()
          Gets the version.
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(org.apache.tools.ant.types.Path classpath)
          Sets the classpath for loading.
 void setClasspathRef(org.apache.tools.ant.types.Reference r)
          Set the classpath for loading using the classpath reference.
 void setOutput(File output)
          Set the output file; optional, defaults to the Ant log.
 void setPrint(boolean print)
          Print results from the statements; optional, default false
 void setSrc(File srcFile)
          Set the name of the file to be run.
 void setUserid(String userId)
          Set the user name for the connection; required.
 void setVersion(String version)
          Sets the version string, execute task only if groovy version match; optional.
 
Methods inherited from class org.apache.tools.ant.Task
getDescription, getLocation, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, maybeConfigure, perform, reconfigure, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
getProject, setProject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Groovy

public Groovy()
Method Detail

setSrc

public void setSrc(File srcFile)
Set the name of the file to be run. 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(org.apache.tools.ant.types.FileSet set)
Adds a set of files (nested fileset attribute).


setPrint

public void setPrint(boolean print)
Print results from the statements; optional, default false


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.

Since:
Ant 1.5

setClasspath

public void setClasspath(org.apache.tools.ant.types.Path classpath)
Sets the classpath for loading.

Parameters:
classpath - The classpath to set

createClasspath

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


setClasspathRef

public void setClasspathRef(org.apache.tools.ant.types.Reference r)
Set the classpath for loading using the classpath reference.


setVersion

public void setVersion(String version)
Sets the version string, execute task only if groovy version match; optional.

Parameters:
version - The version to set

getLoaderMap

protected static Hashtable getLoaderMap()

getClasspath

public org.apache.tools.ant.types.Path getClasspath()
Gets the classpath.

Returns:
Returns a Path

getUserId

public String getUserId()
Gets the userId.

Returns:
Returns a String

setUserid

public void setUserid(String userId)
Set the user name for the connection; required.

Parameters:
userId - The userId to set

getVersion

public String getVersion()
Gets the version.

Returns:
Returns a String

execute

public void execute()
             throws org.apache.tools.ant.BuildException
Load the file and then execute it

Throws:
org.apache.tools.ant.BuildException

runStatements

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

Throws:
IOException

execGroovy

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


printResults

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



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