Package org.codehaus.gmavenplus.mojo
Class AbstractCompileMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- org.codehaus.gmavenplus.mojo.AbstractGroovyMojo
-
- org.codehaus.gmavenplus.mojo.AbstractGroovySourcesMojo
-
- org.codehaus.gmavenplus.mojo.AbstractCompileMojo
-
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo
- Direct Known Subclasses:
CompileMojo,CompileTestsMojo
public abstract class AbstractCompileMojo extends AbstractGroovySourcesMojo
The base compile mojo, which all compile mojos extend.- Since:
- 1.0-beta-1
- Author:
- Keegan Witt
-
-
Field Summary
Fields Modifier and Type Field Description protected FileconfigScriptA script for tweaking the configuration options (requires Groovy 2.1.0-beta-1 or greater).protected booleandebugWhether Groovy compiler should be set to debug.protected static VersionGROOVY_1_6_0Groovy 1.6.0 version.protected static VersionGROOVY_2_0_0_BETA3Groovy 2.0.0 beta-3 version.protected static VersionGROOVY_2_1_0_BETA1Groovy 2.1.0 beta-1 version.protected static VersionGROOVY_2_1_3Groovy 2.1.3 version.protected static VersionGROOVY_2_3_3Groovy 2.3.3 version.protected static VersionGROOVY_2_5_0_ALPHA1Groovy 2.5.0 alpha-1 version.protected booleaninvokeDynamicWhether to support invokeDynamic (requires Java 7 or greater and Groovy indy 2.0.0-beta-3 or greater).protected booleanparametersGenerate metadata for reflection on method parameter names using the functionality provided by JEP 118 (requires Java 8 or greater and Groovy 2.5.0-alpha-1 or greater).protected StringsourceEncodingThe encoding of source files.protected StringtargetBytecodeThe Groovy compiler bytecode compatibility.protected inttoleranceGroovy compiler error tolerance (the number of non-fatal errors (per unit) that should be tolerated before compilation is aborted).protected booleanverboseWhether Groovy compiler should be set to verbose.protected intwarningLevelGroovy compiler warning level.-
Fields inherited from class org.codehaus.gmavenplus.mojo.AbstractGroovySourcesMojo
MAIN, sources, TEST, testSources
-
Fields inherited from class org.codehaus.gmavenplus.mojo.AbstractGroovyMojo
classWrangler, GROOVY_1_5_0, GROOVY_SOURCES_PATTERN, JAVA_1_7, JAVA_1_8, JAVA_SOURCES_PATTERN, minGroovyVersion, mojoExecution, pluginArtifacts, project, session, skipTests
-
-
Constructor Summary
Constructors Constructor Description AbstractCompileMojo()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddoCompile(Set<File> sources, List classpath, File compileOutputDirectory)Performs compilation of compile mojos.protected ObjectsetupCompilationUnit(Set<File> sources, Class<?> compilerConfigurationClass, Class<?> compilationUnitClass, Class<?> groovyClassLoaderClass, Object compilerConfiguration, Object groovyClassLoader, Object transformLoader)Sets up the CompilationUnit to use for compilation.protected ObjectsetupCompilerConfiguration(File compileOutputDirectory, Class<?> compilerConfigurationClass)Sets up the CompilationConfiguration to use for compilation.protected voidverifyGroovyVersionSupportsTargetBytecode()Throws an exception if targetBytecode is not supported with this version of Groovy.-
Methods inherited from class org.codehaus.gmavenplus.mojo.AbstractGroovySourcesMojo
getFiles, getFilesets, getSourceRoots, getSourceRoots, getSources, getSources, getTestSourceRoots, getTestSourceRoots, getTestSources, getTestSources, setSources, setTestSources
-
Methods inherited from class org.codehaus.gmavenplus.mojo.AbstractGroovyMojo
getJavaVersion, getJavaVersionString, groovyAtLeast, groovyIs, groovyNewerThan, groovyOlderThan, groovyVersionSupportsAction, isJavaSupportIndy, isJavaSupportParameters, logPluginClasspath
-
Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
-
-
-
Field Detail
-
GROOVY_2_5_0_ALPHA1
protected static final Version GROOVY_2_5_0_ALPHA1
Groovy 2.5.0 alpha-1 version.
-
GROOVY_2_3_3
protected static final Version GROOVY_2_3_3
Groovy 2.3.3 version.
-
GROOVY_2_1_3
protected static final Version GROOVY_2_1_3
Groovy 2.1.3 version.
-
GROOVY_2_1_0_BETA1
protected static final Version GROOVY_2_1_0_BETA1
Groovy 2.1.0 beta-1 version.
-
GROOVY_2_0_0_BETA3
protected static final Version GROOVY_2_0_0_BETA3
Groovy 2.0.0 beta-3 version.
-
GROOVY_1_6_0
protected static final Version GROOVY_1_6_0
Groovy 1.6.0 version.
-
sourceEncoding
@Parameter(defaultValue="${project.build.sourceEncoding}") protected String sourceEncodingThe encoding of source files.
-
targetBytecode
@Parameter(property="maven.compiler.target", defaultValue="1.5") protected String targetBytecodeThe Groovy compiler bytecode compatibility. One of- 1.4
- 1.5
- 1.6
- 1.7
- 1.8
-
debug
@Parameter(defaultValue="false") protected boolean debug
Whether Groovy compiler should be set to debug.
-
verbose
@Parameter(defaultValue="false") protected boolean verbose
Whether Groovy compiler should be set to verbose.
-
warningLevel
@Parameter(defaultValue="1") protected int warningLevel
Groovy compiler warning level. Should be one of:- 0
- None
- 1
- Likely Errors
- 2
- Possible Errors
- 3
- Paranoia
-
tolerance
@Parameter(defaultValue="0") protected int tolerance
Groovy compiler error tolerance (the number of non-fatal errors (per unit) that should be tolerated before compilation is aborted).
-
invokeDynamic
@Parameter(property="invokeDynamic", defaultValue="false") protected boolean invokeDynamicWhether to support invokeDynamic (requires Java 7 or greater and Groovy indy 2.0.0-beta-3 or greater).
-
configScript
@Parameter(property="configScript") protected File configScript
A script for tweaking the configuration options (requires Groovy 2.1.0-beta-1 or greater). Note that its encoding must match your source encoding.
-
parameters
@Parameter(property="parameters", defaultValue="false") protected boolean parametersGenerate metadata for reflection on method parameter names using the functionality provided by JEP 118 (requires Java 8 or greater and Groovy 2.5.0-alpha-1 or greater).
-
-
Method Detail
-
doCompile
protected void doCompile(Set<File> sources, List classpath, File compileOutputDirectory) throws ClassNotFoundException, InstantiationException, IllegalAccessException, InvocationTargetException, MalformedURLException
Performs compilation of compile mojos.- Parameters:
sources- the sources to compileclasspath- the classpath to use for compilationcompileOutputDirectory- the directory to write the compiled class files to- Throws:
ClassNotFoundException- when a class needed for compilation cannot be foundInstantiationException- when a class needed for compilation cannot be instantiatedIllegalAccessException- when a method needed for compilation cannot be accessedInvocationTargetException- when a reflection invocation needed for compilation cannot be completedMalformedURLException- when a classpath element provides a malformed URL
-
setupCompilationUnit
protected Object setupCompilationUnit(Set<File> sources, Class<?> compilerConfigurationClass, Class<?> compilationUnitClass, Class<?> groovyClassLoaderClass, Object compilerConfiguration, Object groovyClassLoader, Object transformLoader) throws InvocationTargetException, IllegalAccessException, InstantiationException
Sets up the CompilationUnit to use for compilation.- Parameters:
sources- the sources to compilecompilerConfigurationClass- the CompilerConfiguration classcompilationUnitClass- the CompilationUnit classgroovyClassLoaderClass- the GroovyClassLoader classcompilerConfiguration- the CompilerConfigurationgroovyClassLoader- the GroovyClassLoadertransformLoader- the GroovyClassLoader to use for transformation- Returns:
- the CompilationUnit
- Throws:
InstantiationException- when a class needed for setting up compilation unit cannot be instantiatedIllegalAccessException- when a method needed for setting up compilation unit cannot be accessedInvocationTargetException- when a reflection invocation needed for setting up compilation unit cannot be completed
-
setupCompilerConfiguration
protected Object setupCompilerConfiguration(File compileOutputDirectory, Class<?> compilerConfigurationClass) throws InvocationTargetException, IllegalAccessException, InstantiationException, ClassNotFoundException
Sets up the CompilationConfiguration to use for compilation.- Parameters:
compileOutputDirectory- the directory to write the compiled classes tocompilerConfigurationClass- the CompilerConfiguration class- Returns:
- the CompilerConfiguration
- Throws:
ClassNotFoundException- when a class needed for setting up CompilerConfiguration cannot be foundInstantiationException- when a class needed for setting up CompilerConfiguration cannot be instantiatedIllegalAccessException- when a method needed for setting up CompilerConfiguration cannot be accessedInvocationTargetException- when a reflection invocation needed for setting up CompilerConfiguration cannot be completed
-
verifyGroovyVersionSupportsTargetBytecode
protected void verifyGroovyVersionSupportsTargetBytecode()
Throws an exception if targetBytecode is not supported with this version of Groovy. That is, when Groovy added the option to org.codehaus.groovy.control.CompilerConfiguration.
-
-