Top Description Inners Fields Constructors Methods
groovy.ui

public Class GroovyMain

extends Object
Class Inheritance
Imports
groovy.lang.Binding, .GroovyCodeSource, .GroovyRuntimeException, .GroovyShell, .GroovySystem, .MissingMethodException, .Script, org.codehaus.groovy.control.CompilationFailedException, .CompilerConfiguration, org.codehaus.groovy.control.customizers.ImportCustomizer, org.codehaus.groovy.runtime.InvokerHelper, .InvokerInvocationException, .ResourceGroovyMethods, .StackTraceUtils, .StringGroovyMethods, picocli.CommandLine, .CommandLine.Command, .CommandLine.IVersionProvider, .CommandLine.Option, .CommandLine.ParameterException, .CommandLine.ParseResult, .CommandLine.Unmatched, java.io.BufferedReader, .File, .FileNotFoundException, .FileReader, .FileWriter, .IOException, .InputStreamReader, .PrintStream, .PrintWriter, java.math.BigInteger, java.net.URI, .URISyntaxException, .URL, java.security.AccessController, .PrivilegedAction, java.util.ArrayList, .LinkedHashMap, .List, .Map, java.util.regex.Pattern

A Command line to execute groovy.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
public static class

Field Summary

Modifier and TypeField and Description
private List<String>
private boolean
private boolean
private String
private CompilerConfiguration
private boolean
private boolean
private boolean
private int
private boolean
private boolean
private String
private String
private static final Pattern

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static String
private static GroovyShell
protected GroovyCodeSource

Returns:

a new GroovyCodeSource for the given script
getScriptSource
(boolean
indicates whether the script parameter is a location or content
isScriptFile
,
String
the location or context of the script
script
)

Get a new GroovyCodeSource for a script which may be given as a location (isScript is true) or as text (isScript is false).

public String

Returns:

the text content at the location
getText
(String uriOrFilename)

Deprecated
Get the text of the Groovy script at the given location.
public File
huntForTheScriptFile(String input)

Hunt for the script file by calling searchForGroovyScriptFile(String).

public static void
main(String[]
all command line args.
args
)

Main CLI interface.

pack-priv static void
processArgs(String[] args, final PrintStream out)

Deprecated
pack-priv static void
processArgs(String[] args, final PrintStream out, final PrintStream err)

public static void
public static void
private void
processFile(Script
the script to execute.
s
,
File
the input file.
file
)

Process a single input file.

private void
processFiles()

Process the input files.

private void
processOnce()

Process the standard, single script with args.

private void
processReader(Script
script to execute.
s
,
BufferedReader
input file.
reader
,
PrintWriter
output sink.
pw
)

Process a script against a single input file.

private void
processSockets()

Process Sockets.

private boolean
run()

Run the script.

public static File
searchForGroovyScriptFile(String input)

Search for the script file, doesn't bother if it is named precisely.

private static void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

argsback to summary
private List<String> args
autoOutputback to summary
private boolean autoOutput
autoSplitback to summary
private boolean autoSplit
backupExtensionback to summary
private String backupExtension
confback to summary
private CompilerConfiguration conf
debugback to summary
private boolean debug
editFilesback to summary
private boolean editFiles
isScriptFileback to summary
private boolean isScriptFile
portback to summary
private int port
processFilesback to summary
private boolean processFiles
processSocketsback to summary
private boolean processSockets
scriptback to summary
private String script
splitPatternback to summary
private String splitPattern
URI_PATTERNback to summary
private static final Pattern URI_PATTERN

Constructor Detail

GroovyMainback to summary
public GroovyMain()

Method Detail

buildConfigScriptTextback to summary
public static String buildConfigScriptText(List<String> transforms)
createConfigScriptsShellback to summary
private static GroovyShell createConfigScriptsShell(CompilerConfiguration conf)
getScriptSourceback to summary
protected GroovyCodeSource getScriptSource(boolean isScriptFile, String script) throws IOException, URISyntaxException

Get a new GroovyCodeSource for a script which may be given as a location (isScript is true) or as text (isScript is false).

Parameters
isScriptFile:boolean

indicates whether the script parameter is a location or content

script:String

the location or context of the script

Returns:GroovyCodeSource

a new GroovyCodeSource for the given script

Since
2.3.0
getTextback to summary
public String getText(String uriOrFilename) throws IOException

Deprecated

Get the text of the Groovy script at the given location. If the location is a file path and it does not exist as given, then GroovyMain#huntForTheScriptFile(String) is called to try with some Groovy extensions appended. This method is not used to process scripts and is retained for backward compatibility. If you want to modify how GroovyMain processes scripts then use GroovyMain#getScriptSource(boolean, String).

Returns:String

the text content at the location

Annotations
@Deprecated
huntForTheScriptFileback to summary
public File huntForTheScriptFile(String input)

Hunt for the script file by calling searchForGroovyScriptFile(String).

See Also
GroovyMain#searchForGroovyScriptFile(String)
mainback to summary
public static void main(String[] args)

Main CLI interface.

Parameters
args:String[]

all command line args.

processArgsback to summary
pack-priv static void processArgs(String[] args, final PrintStream out)

Deprecated

Annotations
@Deprecated
processArgsback to summary
pack-priv static void processArgs(String[] args, final PrintStream out, final PrintStream err)
processConfigScriptsback to summary
public static void processConfigScripts(List<String> scripts, CompilerConfiguration conf) throws IOException
processConfigScriptTextback to summary
public static void processConfigScriptText(String scriptText, CompilerConfiguration conf)
processFileback to summary
private void processFile(Script s, File file) throws IOException

Process a single input file.

Parameters
s:Script

the script to execute.

file:File

the input file.

processFilesback to summary
private void processFiles() throws CompilationFailedException, IOException, URISyntaxException

Process the input files.

processOnceback to summary
private void processOnce() throws CompilationFailedException, IOException, URISyntaxException

Process the standard, single script with args.

processReaderback to summary
private void processReader(Script s, BufferedReader reader, PrintWriter pw) throws IOException

Process a script against a single input file.

Parameters
s:Script

script to execute.

reader:BufferedReader

input file.

pw:PrintWriter

output sink.

processSocketsback to summary
private void processSockets() throws CompilationFailedException, IOException, URISyntaxException

Process Sockets.

runback to summary
private boolean run()

Run the script.

searchForGroovyScriptFileback to summary
public static File searchForGroovyScriptFile(String input)

Search for the script file, doesn't bother if it is named precisely. Tries in this order: - actual supplied name - name.groovy - name.gvy - name.gy - name.gsh

Since
2.3.0
setupContextClassLoaderback to summary
private static void setupContextClassLoader(GroovyShell shell)
groovy.ui back to summary

private Class GroovyMain.GroovyCommand

extends Object
Class Inheritance
Annotations
@Command
name:groovy
customSynopsis:groovy [options] [filename] [args]
description:The Groovy command line processor.
sortOptions:false
versionProvider:VersionProvider

Field Summary

Modifier and TypeField and Description
pack-priv List<String>
private String
private boolean
private String
private boolean
private List<String>
private String
private String
private boolean
private boolean
private boolean
private boolean
private boolean
private String
private boolean
private String
private String
private String
private Map<String, String>
private boolean
private boolean

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private List<String>
pack-priv boolean
process(CommandLine
the parsed command line. Used when the user input was invalid.
parser
)

Process the users request.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

argumentsback to summary
pack-priv List<String> arguments
Annotations
@Unmatched
classpathback to summary
private String classpath
Annotations
@Option
names:-cp, -classpath, --classpath
paramLabel:
description:Specify where to find the class files - must be first argument
compileStaticback to summary
private boolean compileStatic
Annotations
@Option
names:--compile-static
description:Use CompileStatic
configscriptback to summary
private String configscript
Annotations
@Option
names:--configscript
paramLabel: