Package org.codehaus.gmavenplus.mojo
Class AbstractGroovyMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- org.codehaus.gmavenplus.mojo.AbstractGroovyMojo
-
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled
,org.apache.maven.plugin.Mojo
- Direct Known Subclasses:
AbstractGroovySourcesMojo
,AbstractToolsMojo
public abstract class AbstractGroovyMojo extends org.apache.maven.plugin.AbstractMojo
The base mojo class, which all other mojos extend.- Since:
- 1.0-beta-1
-
-
Field Summary
Fields Modifier and Type Field Description protected ClassWrangler
classWrangler
The wrangler to use to work with Groovy classes, classpaths, classLoaders, and versions.protected static Version
GROOVY_1_5_0
Groovy 1.5.0 version.protected static java.lang.String
GROOVY_SOURCES_PATTERN
The pattern defining Groovy files.protected static Version
JAVA_1_7
Java 1.7 version.protected static Version
JAVA_1_8
Java 1.8 version.protected static Version
JAVA_12
Java 1.8 version.protected static java.lang.String
JAVA_SOURCES_PATTERN
The pattern defining Java stub files.protected Version
minGroovyVersion
The minimum version of Groovy that this mojo supports (1.5.0 by default, but other mojos can override).protected org.apache.maven.plugin.MojoExecution
mojoExecution
The plugin's mojo execution.protected java.util.List<org.apache.maven.artifact.Artifact>
pluginArtifacts
The plugin dependencies.protected org.apache.maven.project.MavenProject
project
The Maven project this plugin is being used on.protected org.apache.maven.execution.MavenSession
session
The Maven Session this plugin is being used on.
-
Constructor Summary
Constructors Constructor Description AbstractGroovyMojo()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Version
getJavaVersion()
Gets the version of Java executing this mojo as a Version object.protected java.lang.String
getJavaVersionString()
Gets the version of Java executing this mojo as a String.protected boolean
groovyAtLeast(Version version)
Determines whether the detected Groovy version is the specified version or newer.protected boolean
groovyIs(Version version)
Determines whether the detected Groovy version is the specified version.protected boolean
groovyNewerThan(Version version)
Determines whether the detected Groovy version is newer than the specified version.protected boolean
groovyOlderThan(Version version)
Determines whether the detected Groovy version is older than the specified version.protected boolean
groovyVersionSupportsAction()
Determines whether this mojo can be run with the version of Groovy supplied.protected boolean
isGroovyIndy()
Gets whether the version of Groovy on the classpath supports invokedynamic.protected boolean
isJavaSupportIndy()
Determines whether the version of Java executing this mojo supports invokedynamic (is at least 1.7).protected boolean
isJavaSupportParameters()
Determines whether the version of Java executing this mojo supports JEP 118 (is at least 1.8).protected boolean
isJavaSupportPreviewFeatures()
Determines whether the version of Java executing this mojo supports preview features (is at least 12).protected void
logPluginClasspath()
Logs the plugin classpath.protected void
setupClassWrangler(java.util.List<?> classpath, IncludeClasspath includeClasspath)
Instantiate a ClassWrangler.-
Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
-
-
-
Field Detail
-
GROOVY_SOURCES_PATTERN
protected static final java.lang.String GROOVY_SOURCES_PATTERN
The pattern defining Groovy files.
-
JAVA_SOURCES_PATTERN
protected static final java.lang.String JAVA_SOURCES_PATTERN
The pattern defining Java stub files.
-
JAVA_1_7
protected static final Version JAVA_1_7
Java 1.7 version.
-
JAVA_1_8
protected static final Version JAVA_1_8
Java 1.8 version.
-
JAVA_12
protected static final Version JAVA_12
Java 1.8 version.
-
GROOVY_1_5_0
protected static final Version GROOVY_1_5_0
Groovy 1.5.0 version.
-
classWrangler
protected ClassWrangler classWrangler
The wrangler to use to work with Groovy classes, classpaths, classLoaders, and versions.
-
project
@Parameter(property="project", required=true, readonly=true) protected org.apache.maven.project.MavenProject project
The Maven project this plugin is being used on.
-
session
@Parameter(property="session", required=true, readonly=true) protected org.apache.maven.execution.MavenSession session
The Maven Session this plugin is being used on.
-
pluginArtifacts
@Parameter(property="plugin.artifacts", required=true, readonly=true) protected java.util.List<org.apache.maven.artifact.Artifact> pluginArtifacts
The plugin dependencies.
-
mojoExecution
@Parameter(property="mojoExecution", required=true, readonly=true) protected org.apache.maven.plugin.MojoExecution mojoExecution
The plugin's mojo execution.
-
minGroovyVersion
protected Version minGroovyVersion
The minimum version of Groovy that this mojo supports (1.5.0 by default, but other mojos can override).
-
-
Method Detail
-
logPluginClasspath
protected void logPluginClasspath()
Logs the plugin classpath.
-
isJavaSupportIndy
protected boolean isJavaSupportIndy()
Determines whether the version of Java executing this mojo supports invokedynamic (is at least 1.7).- Returns:
true
if the running Java supports invokedynamic,false
otherwise
-
isJavaSupportPreviewFeatures
protected boolean isJavaSupportPreviewFeatures()
Determines whether the version of Java executing this mojo supports preview features (is at least 12).- Returns:
true
if the running Java supports preview features,false
otherwise
-
isJavaSupportParameters
protected boolean isJavaSupportParameters()
Determines whether the version of Java executing this mojo supports JEP 118 (is at least 1.8).- Returns:
true
if the running Java supports parameters,false
otherwise
-
getJavaVersion
protected Version getJavaVersion()
Gets the version of Java executing this mojo as a Version object.- Returns:
- a Version object of the running Java version
-
getJavaVersionString
protected java.lang.String getJavaVersionString()
Gets the version of Java executing this mojo as a String.- Returns:
- a String of the running Java version
-
groovyVersionSupportsAction
protected boolean groovyVersionSupportsAction()
Determines whether this mojo can be run with the version of Groovy supplied.- Returns:
true
only if the version of Groovy supports this mojo
-
groovyAtLeast
protected boolean groovyAtLeast(Version version)
Determines whether the detected Groovy version is the specified version or newer.- Parameters:
version
- the version to compare the detected Groovy version to- Returns:
true
if the detected Groovy version is the specified version or newer,false
otherwise
-
groovyIs
protected boolean groovyIs(Version version)
Determines whether the detected Groovy version is the specified version.- Parameters:
version
- the version to compare the detected Groovy version to- Returns:
true
if the detected Groovy version is the specified version,false
otherwise
-
groovyNewerThan
protected boolean groovyNewerThan(Version version)
Determines whether the detected Groovy version is newer than the specified version.- Parameters:
version
- the version to compare the detected Groovy version to- Returns:
true
if the detected Groovy version is newer than the specified version,false
otherwise
-
groovyOlderThan
protected boolean groovyOlderThan(Version version)
Determines whether the detected Groovy version is older than the specified version.- Parameters:
version
- the version to compare the detected Groovy version to- Returns:
true
if the detected Groovy version is older than the specified version,false
otherwise
-
isGroovyIndy
protected boolean isGroovyIndy()
Gets whether the version of Groovy on the classpath supports invokedynamic.- Returns:
true
if the version of Groovy uses invokedynamic,false
if not or Groovy dependency cannot be found
-
setupClassWrangler
protected void setupClassWrangler(java.util.List<?> classpath, IncludeClasspath includeClasspath) throws java.net.MalformedURLException
Instantiate a ClassWrangler.- Parameters:
classpath
- the classpath to load onto a new classloader (if includeClasspath isPROJECT_ONLY
)includeClasspath
- whether to use a shared classloader that includes both the project classpath and plugin classpath.- Throws:
java.net.MalformedURLException
- when a classpath element provides a malformed URL
-
-