Package org.codehaus.groovy.tools
Class FileSystemCompiler
java.lang.Object
org.codehaus.groovy.tools.FileSystemCompiler
Command-line compiler (aka. groovyc).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classCommand-line options accepted by thegroovyclauncher.static classSupplies version text for thegroovyccommand line. -
Constructor Summary
ConstructorsConstructorDescriptionFileSystemCompiler(CompilerConfiguration configuration) Creates a file-system compiler using the supplied configuration.FileSystemCompiler(CompilerConfiguration configuration, CompilationUnit cu) Creates a file-system compiler using the supplied configuration and optional prebuilt compilation unit. -
Method Summary
Modifier and TypeMethodDescriptionstatic intcheckFiles(String[] filenames) Counts unreadable or missing source files in the supplied list.static voidcommandLineCompile(String[] args) Same as main(args) except that exceptions are thrown out instead of causing the VM to exit.static voidcommandLineCompile(String[] args, boolean lookupUnnamedFiles) Same as main(args) except that exceptions are thrown out instead of causing the VM to exit and the lookup for .groovy files can be controlledstatic voidcommandLineCompileWithErrorHandling(String[] args, boolean lookupUnnamedFiles) Primary entry point for compiling from the command line (using the groovyc script).voidCompiles the supplied source files.voidCompiles the sources at the supplied paths.static CommandLineCreates and configures the command-line parser for compilation options.static voiddeleteRecursive(File file) Deletes the supplied file or directory tree if it exists.static voidPrints the usage help message forFileSystemCompiler.CompilationOptionsto stderr.static voiddisplayHelp(PrintWriter writer) Prints the usage help message for theFileSystemCompiler.CompilationOptionsto the specified PrintWriter.static voidPrints version information to stderr.static voiddisplayVersion(PrintWriter writer) Prints version information to the specified PrintWriter.static voiddoCompilation(CompilerConfiguration configuration, CompilationUnit unit, String[] filenames) Compiles the supplied source files using the given configuration.static voiddoCompilation(CompilerConfiguration configuration, CompilationUnit unit, String[] filenames, boolean lookupUnnamedFiles) Compiles the supplied source files using the given configuration and controls whether unnamed Groovy sources are searched relative to the provided file list.static voidPrimary entry point for compiling from the command line (using the groovyc script).static booleanvalidateFiles(String[] filenames) Returns whether all supplied file names resolve to readable files.
-
Constructor Details
-
FileSystemCompiler
Creates a file-system compiler using the supplied configuration.- Parameters:
configuration- the compiler configuration to apply- Throws:
ConfigurationException- if the compilation unit cannot be created
-
FileSystemCompiler
public FileSystemCompiler(CompilerConfiguration configuration, CompilationUnit cu) throws ConfigurationException Creates a file-system compiler using the supplied configuration and optional prebuilt compilation unit.- Parameters:
configuration- the compiler configuration to applycu- an existing compilation unit to reuse, ornullto build a suitable one- Throws:
ConfigurationException- if the compilation unit cannot be created
-
-
Method Details
-
displayHelp
public static void displayHelp()Prints the usage help message forFileSystemCompiler.CompilationOptionsto stderr.- Since:
- 2.5
- See Also:
-
displayHelp
Prints the usage help message for theFileSystemCompiler.CompilationOptionsto the specified PrintWriter.- Since:
- 2.5
-
displayVersion
public static void displayVersion()Prints version information to stderr.- See Also:
-
displayVersion
Prints version information to the specified PrintWriter.- Since:
- 2.5
-
checkFiles
Counts unreadable or missing source files in the supplied list.- Parameters:
filenames- the file names to validate- Returns:
- the number of invalid file entries
-
validateFiles
Returns whether all supplied file names resolve to readable files.- Parameters:
filenames- the file names to validate- Returns:
trueif every file exists and can be read
-
commandLineCompile
Same as main(args) except that exceptions are thrown out instead of causing the VM to exit.- Throws:
Exception
-
commandLineCompile
Same as main(args) except that exceptions are thrown out instead of causing the VM to exit and the lookup for .groovy files can be controlled- Throws:
Exception
-
configureParser
Creates and configures the command-line parser for compilation options.- Parameters:
options- the options object to bind parser results to- Returns:
- the configured parser
-
main
Primary entry point for compiling from the command line (using the groovyc script).If calling inside a process and you don't want the JVM to exit on an error call commandLineCompile(String[]), which this method simply wraps
- Parameters:
args- command line arguments
-
commandLineCompileWithErrorHandling
Primary entry point for compiling from the command line (using the groovyc script).If calling inside a process and you don't want the JVM to exit on an error call commandLineCompile(String[]), which this method simply wraps
- Parameters:
args- command line argumentslookupUnnamedFiles- do a lookup for .groovy files not part of the given list of files to compile
-
doCompilation
public static void doCompilation(CompilerConfiguration configuration, CompilationUnit unit, String[] filenames) throws Exception Compiles the supplied source files using the given configuration.- Parameters:
configuration- the compiler configuration to useunit- an existing compilation unit to reuse, ornullfilenames- the source files to compile- Throws:
Exception- if compilation fails
-
doCompilation
public static void doCompilation(CompilerConfiguration configuration, CompilationUnit unit, String[] filenames, boolean lookupUnnamedFiles) throws Exception Compiles the supplied source files using the given configuration and controls whether unnamed Groovy sources are searched relative to the provided file list.- Parameters:
configuration- the compiler configuration to useunit- an existing compilation unit to reuse, ornullfilenames- the source files to compilelookupUnnamedFiles- whether to search for unnamed Groovy sources beside the listed files- Throws:
Exception- if compilation fails
-
deleteRecursive
Deletes the supplied file or directory tree if it exists.- Parameters:
file- the file or directory to delete
-
compile
Compiles the sources at the supplied paths.- Parameters:
paths- the source paths to compile- Throws:
Exception- if compilation fails
-
compile
Compiles the supplied source files.- Parameters:
files- the source files to compile- Throws:
Exception- if compilation fails
-