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
- Author:
- Keegan Witt
-
-
Field Summary
Fields Modifier and Type Field Description protected booleandebugWhether Groovy compiler should be set to debug.protected static VersionGROOVY_1_8_3Groovy 1.8.3 version.protected static VersionGROOVY_1_9_0_BETA1Groovy 2.9.0 beta-1 version.protected static VersionGROOVY_1_9_0_BETA3Groovy 1.9.0 beta-3 version.protected Set<String>scriptExtensionsThe file extensions of Groovy source files.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.AbstractGroovyStubSourcesMojo
stubsOutputDirectory, testStubsOutputDirectory
-
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_SOURCES_PATTERN, minGroovyVersion, mojoExecution, pluginArtifacts, project, session, skipTests
-
-
Constructor Summary
Constructors Constructor Description AbstractGenerateStubsMojo()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddGroovySources(Set<File> stubSources, Class compilerConfigurationClass, Class javaStubCompilationUnitClass, Object compilerConfiguration, Object javaStubCompilationUnit)Adds the Groovy sources to the CompilationUnit.protected voiddoStubGeneration(Set<File> stubSources, List classpath, File outputDirectory)Performs the stub generation on the specified source files.protected voidresetStubModifiedDates(Set<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 ObjectsetupCompilerConfiguration(File outputDirectory, Class compilerConfigurationClass)Sets up the CompilerConfiguration to use for stub generation.-
Methods inherited from class org.codehaus.gmavenplus.mojo.AbstractGroovyStubSourcesMojo
getStubs, getTestStubs
-
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, groovyVersionSupportsAction, isJavaSupportIndy, logPluginClasspath
-
Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
-
-
-
Field Detail
-
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_3
protected static final Version GROOVY_1_8_3
Groovy 1.8.3 version.
-
sourceEncoding
protected String sourceEncoding
The encoding of source files.
-
scriptExtensions
protected Set<String> scriptExtensions
The file extensions of Groovy source files.- Since:
- 1.0-beta-2
-
targetBytecode
protected String targetBytecode
The Groovy compiler bytecode compatibility. One of- 1.4
- 1.5
- 1.6
- 1.7
- 1.8
- Since:
- 1.0-beta-3
-
debug
protected boolean debug
Whether Groovy compiler should be set to debug.
-
verbose
protected boolean verbose
Whether Groovy compiler should be set to verbose.
-
warningLevel
protected int warningLevel
Groovy compiler warning level. Should be one of:- 0
- None
- 1
- Likely Errors
- 2
- Possible Errors
- 3
- Paranoia
-
tolerance
protected int tolerance
Groovy compiler error tolerance (the number of non-fatal errors (per unit) that should be tolerated before compilation is aborted).
-
-
Method Detail
-
doStubGeneration
protected void doStubGeneration(Set<File> stubSources, List classpath, File outputDirectory) throws ClassNotFoundException, InvocationTargetException, IllegalAccessException, InstantiationException, 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:
ClassNotFoundException- when a class needed for stub generation cannot be foundInstantiationException- when a class needed for stub generation cannot be instantiatedIllegalAccessException- when a method needed for stub generation cannot be accessedInvocationTargetException- when a reflection invocation needed for stub generation cannot be completedMalformedURLException- when a classpath element provides a malformed URL
-
setupCompilerConfiguration
protected Object setupCompilerConfiguration(File outputDirectory, Class compilerConfigurationClass) throws InvocationTargetException, IllegalAccessException, 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:
InstantiationException- when a class needed for stub generation cannot be instantiatedIllegalAccessException- when a method needed for stub generation cannot be accessedInvocationTargetException- when a reflection invocation needed for stub generation cannot be completed
-
addGroovySources
protected void addGroovySources(Set<File> stubSources, Class compilerConfigurationClass, Class javaStubCompilationUnitClass, Object compilerConfiguration, Object javaStubCompilationUnit) throws InvocationTargetException, 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:
IllegalAccessException- when a method needed for stub generation cannot be accessedInvocationTargetException- when a reflection invocation needed for stub generation cannot be completed
-
resetStubModifiedDates
protected void resetStubModifiedDates(Set<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
-
-