Package org.codehaus.gmavenplus.mojo
Class AbstractGenerateStubsMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- org.codehaus.gmavenplus.mojo.AbstractGroovyMojo
-
- org.codehaus.gmavenplus.mojo.AbstractGroovySourcesMojo
-
- org.codehaus.gmavenplus.mojo.AbstractGroovyStubSourcesMojo
-
- org.codehaus.gmavenplus.mojo.AbstractGenerateStubsMojo
-
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled
,org.apache.maven.plugin.Mojo
- Direct Known Subclasses:
GenerateStubsMojo
,GenerateTestStubsMojo
public abstract class AbstractGenerateStubsMojo extends AbstractGroovyStubSourcesMojo
The base generate stubs mojo, which all generate stubs mojos extend.- Since:
- 1.0-beta-1
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
debug
Whether Groovy compiler should be set to debug.protected static Version
GROOVY_1_8_2
Groovy 1.8.2 version.protected static Version
GROOVY_1_8_3
Groovy 1.8.3 version.protected static Version
GROOVY_1_9_0_BETA1
Groovy 2.9.0 beta-1 version.protected static Version
GROOVY_1_9_0_BETA3
Groovy 1.9.0 beta-3 version.protected static Version
GROOVY_2_1_3
Groovy 2.1.3 version.protected static Version
GROOVY_2_3_3
Groovy 2.3.3 version.protected static Version
GROOVY_2_5_3
Groovy 2.5.3 version.protected static Version
GROOVY_2_5_7
Groovy 2.5.7 version.protected static Version
GROOVY_2_6_0_ALPHA1
Groovy 2.6.0 alpha-1 version.protected static Version
GROOVY_2_6_0_ALPHA4
Groovy 2.6.0 alpha-4 version.protected static Version
GROOVY_3_0_0_ALPHA1
Groovy 3.0.0 alpha-1 version.protected static Version
GROOVY_3_0_0_ALPHA2
Groovy 3.0.0 alpha-2 version.protected static Version
GROOVY_3_0_0_ALPHA4
Groovy 3.0.0 alpha-4 version.protected static Version
GROOVY_3_0_0_BETA1
Groovy 3.0.0 beta-1 version.protected static Version
GROOVY_3_0_0_BETA2
Groovy 3.0.0 beta-2 version.protected static Version
GROOVY_3_0_3
Groovy 3.0.3 version.protected static Version
GROOVY_3_0_6
Groovy 3.0.6 version.protected static Version
GROOVY_3_0_8
Groovy 3.0.8 version.protected static Version
GROOVY_4_0_0_ALPHA1
Groovy 4.0.0 alpha-1 version.protected static Version
GROOVY_4_0_0_ALPHA3
Groovy 4.0.0 alpha-3 version.protected static Version
GROOVY_4_0_0_BETA1
Groovy 4.0.0 beta-1 version.protected IncludeClasspath
includeClasspath
What classpath to include.protected boolean
skipBytecodeCheck
Whether to check that the version of Groovy used is able to use the requestedtargetBytecode
.protected java.lang.String
sourceEncoding
The encoding of source files.protected java.lang.String
targetBytecode
The Groovy compiler bytecode compatibility.protected int
tolerance
Groovy compiler error tolerance (the number of non-fatal errors (per unit) that should be tolerated before compilation is aborted).protected boolean
verbose
Whether Groovy compiler should be set to verbose.protected int
warningLevel
Groovy compiler warning level.-
Fields inherited from class org.codehaus.gmavenplus.mojo.AbstractGroovySourcesMojo
MAIN, TEST
-
Fields inherited from class org.codehaus.gmavenplus.mojo.AbstractGroovyMojo
classWrangler, GROOVY_1_5_0, GROOVY_SOURCES_PATTERN, JAVA_1_7, JAVA_1_8, JAVA_12, JAVA_SOURCES_PATTERN, minGroovyVersion, mojoExecution, pluginArtifacts, project, session
-
-
Constructor Summary
Constructors Constructor Description AbstractGenerateStubsMojo()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addGroovySources(java.util.Set<java.io.File> stubSources, java.lang.Class<?> compilerConfigurationClass, java.lang.Class<?> javaStubCompilationUnitClass, java.lang.Object compilerConfiguration, java.lang.Object javaStubCompilationUnit)
Adds the Groovy sources to the CompilationUnit.protected void
doStubGeneration(java.util.Set<java.io.File> stubSources, java.util.List<?> classpath, java.io.File outputDirectory)
Performs the stub generation on the specified source files.protected void
logGeneratedStubs(java.io.File outputDirectory)
Logs the stubs that have been generated.protected void
resetStubModifiedDates(java.util.Set<java.io.File> stubs)
This is a fix for http://jira.codehaus.org/browse/MGROOVY-187 It modifies the dates of the created stubs to 1/1/1970, ensuring that the Java compiler will not overwrite perfectly good compiled Groovy just because it has a newer source stub.protected java.lang.Object
setupCompilerConfiguration(java.io.File outputDirectory, java.lang.Class<?> compilerConfigurationClass)
Sets up the CompilerConfiguration to use for stub generation.protected boolean
supportsSettingExtensions()
Determines whether the version of Groovy supports stub generation.protected void
verifyGroovyVersionSupportsTargetBytecode()
Throws an exception if targetBytecode is not supported with this version of Groovy.-
Methods inherited from class org.codehaus.gmavenplus.mojo.AbstractGroovyStubSourcesMojo
getStubs
-
Methods inherited from class org.codehaus.gmavenplus.mojo.AbstractGroovySourcesMojo
getFiles, getFilesets, getTestFiles, getTestFilesets
-
Methods inherited from class org.codehaus.gmavenplus.mojo.AbstractGroovyMojo
getJavaVersion, getJavaVersionString, groovyAtLeast, groovyIs, groovyNewerThan, groovyOlderThan, groovyVersionSupportsAction, isGroovyIndy, isJavaSupportIndy, isJavaSupportParameters, isJavaSupportPreviewFeatures, logPluginClasspath, setupClassWrangler
-
Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
-
-
-
Field Detail
-
GROOVY_4_0_0_BETA1
protected static final Version GROOVY_4_0_0_BETA1
Groovy 4.0.0 beta-1 version.
-
GROOVY_4_0_0_ALPHA3
protected static final Version GROOVY_4_0_0_ALPHA3
Groovy 4.0.0 alpha-3 version.
-
GROOVY_4_0_0_ALPHA1
protected static final Version GROOVY_4_0_0_ALPHA1
Groovy 4.0.0 alpha-1 version.
-
GROOVY_3_0_8
protected static final Version GROOVY_3_0_8
Groovy 3.0.8 version.
-
GROOVY_3_0_6
protected static final Version GROOVY_3_0_6
Groovy 3.0.6 version.
-
GROOVY_3_0_3
protected static final Version GROOVY_3_0_3
Groovy 3.0.3 version.
-
GROOVY_3_0_0_BETA2
protected static final Version GROOVY_3_0_0_BETA2
Groovy 3.0.0 beta-2 version.
-
GROOVY_3_0_0_BETA1
protected static final Version GROOVY_3_0_0_BETA1
Groovy 3.0.0 beta-1 version.
-
GROOVY_3_0_0_ALPHA4
protected static final Version GROOVY_3_0_0_ALPHA4
Groovy 3.0.0 alpha-4 version.
-
GROOVY_3_0_0_ALPHA2
protected static final Version GROOVY_3_0_0_ALPHA2
Groovy 3.0.0 alpha-2 version.
-
GROOVY_3_0_0_ALPHA1
protected static final Version GROOVY_3_0_0_ALPHA1
Groovy 3.0.0 alpha-1 version.
-
GROOVY_2_6_0_ALPHA4
protected static final Version GROOVY_2_6_0_ALPHA4
Groovy 2.6.0 alpha-4 version.
-
GROOVY_2_6_0_ALPHA1
protected static final Version GROOVY_2_6_0_ALPHA1
Groovy 2.6.0 alpha-1 version.
-
GROOVY_2_5_7
protected static final Version GROOVY_2_5_7
Groovy 2.5.7 version.
-
GROOVY_2_5_3
protected static final Version GROOVY_2_5_3
Groovy 2.5.3 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_1_9_0_BETA1
protected static final Version GROOVY_1_9_0_BETA1
Groovy 2.9.0 beta-1 version.
-
GROOVY_1_9_0_BETA3
protected static final Version GROOVY_1_9_0_BETA3
Groovy 1.9.0 beta-3 version.
-
GROOVY_1_8_2
protected static final Version GROOVY_1_8_2
Groovy 1.8.2 version.
-
GROOVY_1_8_3
protected static final Version GROOVY_1_8_3
Groovy 1.8.3 version.
-
sourceEncoding
@Parameter(defaultValue="${project.build.sourceEncoding}") protected java.lang.String sourceEncoding
The encoding of source files.
-
targetBytecode
@Parameter(property="maven.compiler.target", defaultValue="1.8") protected java.lang.String targetBytecode
The Groovy compiler bytecode compatibility. One of- 1.4
- 1.5
- 1.6
- 1.7
- 1.8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- Since:
- 1.0-beta-3
-
skipBytecodeCheck
@Parameter(property="skipBytecodeCheck", defaultValue="false") protected boolean skipBytecodeCheck
Whether to check that the version of Groovy used is able to use the requestedtargetBytecode
.- Since:
- 1.9.0
-
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).
-
includeClasspath
@Parameter(defaultValue="PROJECT_ONLY") protected IncludeClasspath includeClasspath
What classpath to include. One of- PROJECT_ONLY
- PROJECT_AND_PLUGIN
- PLUGIN_ONLY
- Since:
- 1.8.0
-
-
Method Detail
-
doStubGeneration
protected void doStubGeneration(java.util.Set<java.io.File> stubSources, java.util.List<?> classpath, java.io.File outputDirectory) throws java.lang.ClassNotFoundException, java.lang.reflect.InvocationTargetException, java.lang.IllegalAccessException, java.lang.InstantiationException, java.net.MalformedURLException
Performs the stub generation on the specified source files.- Parameters:
stubSources
- the sources to perform stub generation onclasspath
- The classpath to use for compilationoutputDirectory
- the directory to write the stub files to- Throws:
java.lang.ClassNotFoundException
- when a class needed for stub generation cannot be foundjava.lang.InstantiationException
- when a class needed for stub generation cannot be instantiatedjava.lang.IllegalAccessException
- when a method needed for stub generation cannot be accessedjava.lang.reflect.InvocationTargetException
- when a reflection invocation needed for stub generation cannot be completedjava.net.MalformedURLException
- when a classpath element provides a malformed URL
-
setupCompilerConfiguration
protected java.lang.Object setupCompilerConfiguration(java.io.File outputDirectory, java.lang.Class<?> compilerConfigurationClass) throws java.lang.reflect.InvocationTargetException, java.lang.IllegalAccessException, java.lang.InstantiationException
Sets up the CompilerConfiguration to use for stub generation.- Parameters:
outputDirectory
- the directory to write the stub files tocompilerConfigurationClass
- the CompilerConfiguration class- Returns:
- the CompilerConfiguration to use for stub generation
- Throws:
java.lang.InstantiationException
- when a class needed for stub generation cannot be instantiatedjava.lang.IllegalAccessException
- when a method needed for stub generation cannot be accessedjava.lang.reflect.InvocationTargetException
- when a reflection invocation needed for stub generation cannot be completed
-
addGroovySources
protected void addGroovySources(java.util.Set<java.io.File> stubSources, java.lang.Class<?> compilerConfigurationClass, java.lang.Class<?> javaStubCompilationUnitClass, java.lang.Object compilerConfiguration, java.lang.Object javaStubCompilationUnit) throws java.lang.reflect.InvocationTargetException, java.lang.IllegalAccessException
Adds the Groovy sources to the CompilationUnit.- Parameters:
stubSources
- the sources to perform stub generation oncompilerConfigurationClass
- the CompilerConfiguration classjavaStubCompilationUnitClass
- the JavaStubCompilationUnit classcompilerConfiguration
- the CompilerConfiguration to use for stub generationjavaStubCompilationUnit
- the JavaStubCompilationUnit to use for stub generation- Throws:
java.lang.IllegalAccessException
- when a method needed for stub generation cannot be accessedjava.lang.reflect.InvocationTargetException
- when a reflection invocation needed for stub generation cannot be completed
-
supportsSettingExtensions
protected boolean supportsSettingExtensions()
Determines whether the version of Groovy supports stub generation.- Returns:
true
if the version of Groovy supports stub generation,false
otherwise
-
logGeneratedStubs
protected void logGeneratedStubs(java.io.File outputDirectory)
Logs the stubs that have been generated.- Parameters:
outputDirectory
- the output directory for the stubs
-
resetStubModifiedDates
protected void resetStubModifiedDates(java.util.Set<java.io.File> stubs)
This is a fix for http://jira.codehaus.org/browse/MGROOVY-187 It modifies the dates of the created stubs to 1/1/1970, ensuring that the Java compiler will not overwrite perfectly good compiled Groovy just because it has a newer source stub. Basically, this prevents the stubs from causing a side-effect with the Java compiler, but still allows stubs to work with JavaDoc.- Parameters:
stubs
- the files on which to reset the modified date
-
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 and used it in org.codehaus.groovy.classgen.asm.WriterController.
-
-