Package org.codehaus.groovy.ant
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
-
-
Field Summary
-
Fields inherited from class org.apache.tools.ant.taskdefs.Java
redirector, redirectorElement
-
Fields inherited from class org.apache.tools.ant.ProjectComponent
description, location, project
-
-
Constructor Summary
Constructors Constructor Description Groovy()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddClassPathes(GroovyClassLoader classLoader)Adds the class paths (if any)voidaddFileset(FileSet set)Adds a set of files (nested fileset attribute).voidaddText(String txt)Set an inline command to execute.Commandline.ArgumentcreateArg()PathcreateClasspath()Returns a new path element that can be configured.protected voidexecGroovy(String txt, PrintStream out)Exec the statement.voidexecute()Load the file and then execute itPathgetClasspath()Gets the classpath.static voidmain(String[] args)protected voidprintResults(PrintStream out)print any results in the statement.protected voidrunStatements(Reader reader, PrintStream out)Read in lines and execute them.voidsetAppend(boolean append)Whether output should be appended to or overwrite an existing file.voidsetClasspath(Path classpath)Sets the classpath for loading.voidsetClasspathRef(Reference ref)Set the classpath for loading using the classpath reference.voidsetConfigscript(String configscript)Sets the configuration script for the groovy compiler configuration.voidsetContextClassLoader(boolean contextClassLoader)Setting to true will cause the contextClassLoader to be set with the classLoader of the shell used to run the script.voidsetFork(boolean fork)Should the script be executed using a forked process.voidsetIncludeAntRuntime(boolean includeAntRuntime)Should the system classpath be included on the classpath when forking.voidsetIndy(boolean indy)Sets the indy flag to enable or disable invokedynamicvoidsetOutput(File output)Set the output file; optional, defaults to the Ant log.voidsetScriptBaseClass(String scriptBaseClass)Set the script base class namevoidsetSrc(File srcFile)Set the name of the file to be run.voidsetStacktrace(boolean stacktrace)Enable compiler to report stack trace information if a problem occurs during compilation.voidsetUseGroovyShell(boolean useGroovyShell)Should a new GroovyShell be used when forking.-
Methods inherited from class org.apache.tools.ant.taskdefs.Java
addAssertions, addConfiguredRedirector, addEnv, addSysproperty, addSyspropertyset, checkConfiguration, clearArgs, createBootclasspath, createJvmarg, createModulepath, createPermissions, createUpgrademodulepath, createWatchdog, executeJava, executeJava, getCommandLine, getSysProperties, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, maybeSetResultPropertyValue, run, setArgs, setClassname, setCloneVm, setDir, setDiscardError, setDiscardOutput, setError, setErrorProperty, setFailonerror, setInput, setInputString, setJar, setJvm, setJvmargs, setJVMVersion, setLogError, setMaxmemory, setModule, setModulepath, setModulepathRef, setNewenvironment, setOutputproperty, setResultProperty, setSourceFile, setSpawn, setTimeout, setupRedirector
-
Methods inherited from class org.apache.tools.ant.Task
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, 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
-
-
-
-
Method Detail
-
setFork
public void setFork(boolean fork)
Should the script be executed using a forked process. Defaults to false.
-
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
-
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
-
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- Parameters:
srcFile- the file containing the groovy script to execute
-
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 commands to execute
-
addFileset
public void addFileset(FileSet set)
Adds a set of files (nested fileset attribute).- Parameters:
set- the fileset representing source files
-
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.
-
setClasspath
public void setClasspath(Path classpath)
Sets the classpath for loading.- Overrides:
setClasspathin classJava- 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.- Overrides:
createClasspathin classJava- Returns:
- the resulting created path
-
setClasspathRef
public void setClasspathRef(Reference ref)
Set the classpath for loading using the classpath reference.- Overrides:
setClasspathRefin classJava- Parameters:
ref- the refid to use
-
getClasspath
public Path getClasspath()
Gets the classpath.- Returns:
- Returns a Path
-
setConfigscript
public void setConfigscript(String configscript)
Sets the configuration script for the groovy compiler configuration.- Parameters:
configscript- path to the configuration script
-
setIndy
public void setIndy(boolean indy)
Sets the indy flag to enable or disable invokedynamic- Parameters:
indy- true means invokedynamic support is active
-
setScriptBaseClass
public void setScriptBaseClass(String scriptBaseClass)
Set the script base class name- Parameters:
scriptBaseClass- the name of the base class for scripts
-
execute
public void execute() throws BuildExceptionLoad the file and then execute it- Overrides:
executein classJava- 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 execout- the outputstream to use- Throws:
IOException- if something goes wrong
-
execGroovy
protected void execGroovy(String txt, PrintStream out)
Exec the statement.- Parameters:
txt- the groovy source to execout- not used?
-
main
public static void main(String[] args)
-
addClassPathes
protected void addClassPathes(GroovyClassLoader classLoader)
Adds the class paths (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
-
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
-
-