|
Groovy 2.2.0 | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.codehaus.groovy.control.CompilerConfiguration
public class CompilerConfiguration extends Object
Compilation control flags and coordination stuff.
Field Summary | |
---|---|
static CompilerConfiguration |
DEFAULT
A convenience for getting a default configuration. |
static String |
JDK4
This ( |
static String |
JDK5
This ( |
static String |
JDK6
This ( |
static String |
JDK7
This ( |
static String |
JDK8
This ( |
static String |
POST_JDK5
This ( |
static String |
PRE_JDK5
This ( |
static String |
currentJVMVersion
|
Constructor Summary | |
CompilerConfiguration()
|
|
CompilerConfiguration(CompilerConfiguration configuration)
Copy constructor. |
|
CompilerConfiguration(Properties configuration)
Sets the Flags to the specified configuration, with defaults for those not supplied. |
Method Summary | |
---|---|
CompilerConfiguration
|
addCompilationCustomizers(CompilationCustomizer... customizers)
|
void
|
configure(Properties configuration)
|
List
|
getClasspath()
Returns true if debugging operation has been requested. |
List
|
getCompilationCustomizers()
|
boolean
|
getDebug()
|
String
|
getDefaultScriptExtension()
|
Set
|
getDisabledGlobalASTTransformations()
|
Map
|
getJointCompilationOptions()
Adds compilation customizers to the compilation process. |
int
|
getMinimumRecompilationInterval()
|
Map
|
getOptimizationOptions()
Returns the list of disabled global AST transformation class names. |
PrintWriter
|
getOutput()
|
ParserPluginFactory
|
getPluginFactory()
|
boolean
|
getRecompileGroovySource()
|
String
|
getScriptBaseClass()
|
Set
|
getScriptExtensions()
|
String
|
getSourceEncoding()
Gets the target directory for writing classes. |
String
|
getTargetBytecode()
Gets the optimization options for this configuration. |
File
|
getTargetDirectory()
|
int
|
getTolerance()
|
boolean
|
getVerbose()
|
int
|
getWarningLevel()
Gets the currently configured warning level. |
static boolean
|
isPostJDK5(String bytecodeVersion)
Checks if the specified bytecode version string represents a JDK 1.7+ compatible bytecode version. |
static boolean
|
isPostJDK7(String bytecodeVersion)
Method to configure a this CompilerConfiguration by using Properties. |
void
|
setClasspath(String classpath)
Turns debugging operation on or off. |
void
|
setClasspathList(List parts)
Returns the requested error tolerance. |
void
|
setDebug(boolean debug)
|
void
|
setDefaultScriptExtension(String defaultScriptExtension)
|
void
|
setDisabledGlobalASTTransformations(Set disabledGlobalASTTransformations)
|
void
|
setJointCompilationOptions(Map options)
Returns the list of compilation customizers. |
void
|
setMinimumRecompilationInterval(int time)
|
void
|
setOptimizationOptions(Map options)
Disables global AST transformations. |
void
|
setOutput(PrintWriter output)
|
void
|
setPluginFactory(ParserPluginFactory pluginFactory)
|
void
|
setRecompileGroovySource(boolean recompile)
|
void
|
setScriptBaseClass(String scriptBaseClass)
|
void
|
setScriptExtensions(Set scriptExtensions)
|
void
|
setSourceEncoding(String encoding)
|
void
|
setTargetBytecode(String version)
Sets the joint compilation options for this configuration. |
void
|
setTargetDirectory(String directory)
|
void
|
setTargetDirectory(File directory)
Turns verbose operation on or off. |
void
|
setTolerance(int tolerance)
|
void
|
setVerbose(boolean verbose)
|
void
|
setWarningLevel(int level)
|
Methods inherited from class Object | |
---|---|
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
Field Detail |
---|
public static final CompilerConfiguration DEFAULT
new CompilerConfiguration()
.
public static final String JDK4
"1.4"
) is the value for targetBytecode to compile for a JDK 1.4. *
public static final String JDK5
"1.5"
) is the value for targetBytecode to compile for a JDK 1.5. *
public static final String JDK6
"1.6"
) is the value for targetBytecode to compile for a JDK 1.6. *
public static final String JDK7
"1.7"
) is the value for targetBytecode to compile for a JDK 1.7. *
public static final String JDK8
"1.8"
) is the value for targetBytecode to compile for a JDK 1.8. *
public static final String POST_JDK5
"1.5"
) is the value for targetBytecode to compile for a JDK 1.5 or later JVM. *
public static final String PRE_JDK5
"1.4"
) is the value for targetBytecode to compile for a JDK 1.4 JVM. *
public static final String currentJVMVersion
Constructor Detail |
---|
public CompilerConfiguration()
public CompilerConfiguration(CompilerConfiguration configuration)
An example of this copy constructor at work:
// In all likelihood there is already a configuration in your code's context // for you to copy, but for the sake of this example we'll use the global default. CompilerConfiguration myConfiguration = new CompilerConfiguration(CompilerConfiguration.DEFAULT); myConfiguration.setDebug(true);
configuration
- The configuration to copy.
public CompilerConfiguration(Properties configuration)
If you want to set a few flags but keep Groovy's default
configuration behavior then be sure to make your settings in
a Properties that is backed by System.getProperties()
(which
is done using this constructor). That might be done like this:
Properties myProperties = new Properties(System.getProperties()); myProperties.setProperty("groovy.output.debug", "true"); myConfiguration = new CompilerConfiguration(myProperties);And you also have to contend with a possible SecurityException when getting the system properties (See System.getProperties). A safer approach would be to copy a default CompilerConfiguration and make your changes there using the setter:
// In all likelihood there is already a configuration for you to copy, // but for the sake of this example we'll use the global default. CompilerConfiguration myConfiguration = new CompilerConfiguration(CompilerConfiguration.DEFAULT); myConfiguration.setDebug(true);Another reason to use the copy constructor rather than this one is that you must call setOutput. Calling
setOutput(null)
is valid and will
set up a PrintWriter
to a bit bucket. The copy constructor will of course set
the same one as the original.
Property Key | Get/Set Property Name |
---|---|
"groovy.warnings" | getWarningLevel |
"groovy.source.encoding" | getSourceEncoding |
"groovy.target.directory" | getTargetDirectory |
"groovy.target.bytecode" | getTargetBytecode |
"groovy.classpath" | getClasspath |
"groovy.output.verbose" | getVerbose |
"groovy.output.debug" | getDebug |
"groovy.errors.tolerance" | getTolerance |
"groovy.script.extension" | getDefaultScriptExtension |
"groovy.script.base" | getScriptBaseClass |
"groovy.recompile" | getRecompileGroovySource |
"groovy.recompile.minimumInterval" | getMinimumRecompilationInterval |
configuration
- The properties to get flag values from.
Method Detail |
---|
public CompilerConfiguration addCompilationCustomizers(CompilationCustomizer... customizers)
public void configure(Properties configuration)
public List getClasspath()
public List getCompilationCustomizers()
public boolean getDebug()
public String getDefaultScriptExtension()
public Set getDisabledGlobalASTTransformations()
public Map getJointCompilationOptions()
customizers
- the list of customizers to be added
public int getMinimumRecompilationInterval()
public Map getOptimizationOptions()
public PrintWriter getOutput()
public ParserPluginFactory getPluginFactory()
public boolean getRecompileGroovySource()
public String getScriptBaseClass()
public Set getScriptExtensions()
public String getSourceEncoding()
public String getTargetBytecode()
public File getTargetDirectory()
public int getTolerance()
public boolean getVerbose()
public int getWarningLevel()
public static boolean isPostJDK5(String bytecodeVersion)
bytecodeVersion
- the bytecode version string (1.4, 1.5, 1.6, 1.7 or 1.8)
public static boolean isPostJDK7(String bytecodeVersion)
configuration
- The properties to get flag values from.
public void setClasspath(String classpath)
public void setClasspathList(List parts)
public void setDebug(boolean debug)
public void setDefaultScriptExtension(String defaultScriptExtension)
public void setDisabledGlobalASTTransformations(Set disabledGlobalASTTransformations)
public void setJointCompilationOptions(Map options)
public void setMinimumRecompilationInterval(int time)
public void setOptimizationOptions(Map options)
disabledGlobalASTTransformations
- a set of fully qualified class names of global AST transformations
which should not be loaded.
public void setOutput(PrintWriter output)
public void setPluginFactory(ParserPluginFactory pluginFactory)
public void setRecompileGroovySource(boolean recompile)
public void setScriptBaseClass(String scriptBaseClass)
public void setScriptExtensions(Set scriptExtensions)
public void setSourceEncoding(String encoding)
public void setTargetBytecode(String version)
options
- the options
public void setTargetDirectory(String directory)
public void setTargetDirectory(File directory)
public void setTolerance(int tolerance)
public void setVerbose(boolean verbose)
public void setWarningLevel(int level)
Copyright © 2003-2013 The Codehaus. All rights reserved.