Package org.codehaus.gmavenplus.mojo
Class ExecuteMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- org.codehaus.gmavenplus.mojo.AbstractGroovyMojo
-
- org.codehaus.gmavenplus.mojo.AbstractToolsMojo
-
- org.codehaus.gmavenplus.mojo.ExecuteMojo
-
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled
,org.apache.maven.plugin.Mojo
@Mojo(name="execute", requiresDependencyResolution=TEST, threadSafe=true) public class ExecuteMojo extends AbstractToolsMojo
Executes Groovy scripts (in the pom or external), bound to the current project. Note that this mojo requires Groovy >= 1.5.0. Note that it references the plugin classloader to pull in dependencies Groovy didn't include (for things like Ant for AntBuilder, Ivy for @grab, and Jansi for Groovysh).- Since:
- 1.0-beta-1
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
continueExecuting
Whether to continue executing remaining scripts when a script fails.protected static Version
GROOVY_1_7_0
Groovy 1.7.0 version.protected java.lang.String[]
scripts
Groovy scripts to run (in order).protected boolean
skipScriptExecution
Flag to allow script execution to be skipped.protected java.lang.String
sourceEncoding
The encoding of script files.-
Fields inherited from class org.codehaus.gmavenplus.mojo.AbstractToolsMojo
allowSystemExits, bindAllProjectProperties, bindAllSessionUserProperties, bindPropertiesToSeparateVariables, bindSessionUserOverrideProperties, includeClasspath, projectHelper, properties
-
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 ExecuteMojo()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
doExecute()
Does the actual execution.void
execute()
Executes this mojo.protected void
executeScriptFromUrl(java.lang.Class<?> groovyShellClass, java.lang.Object shell, java.lang.String script)
Executes a script at a URL location.protected void
executeScripts(java.lang.Class<?> groovyShellClass, java.lang.Object shell)
Executes the configured scripts.protected java.lang.Object
setupShell(java.lang.Class<?> groovyShellClass)
Instantiates a new groovy.lang.GroovyShell object.-
Methods inherited from class org.codehaus.gmavenplus.mojo.AbstractToolsMojo
initializeProperties, logUnableToInitializeAntBuilder
-
Methods inherited from class org.codehaus.gmavenplus.mojo.AbstractGroovyMojo
getJavaVersion, getJavaVersionString, groovyAtLeast, groovyIs, groovyNewerThan, groovyOlderThan, groovyVersionSupportsAction, isGroovyIndy, isJavaSupportIndy, isJavaSupportParameters, isJavaSupportPreviewFeatures, logPluginClasspath, setupClassWrangler
-
-
-
-
Field Detail
-
GROOVY_1_7_0
protected static final Version GROOVY_1_7_0
Groovy 1.7.0 version.
-
scripts
@Parameter(required=true) protected java.lang.String[] scripts
Groovy scripts to run (in order). Can be a script body, aURL
to a script (local or remote), or a filename.
-
continueExecuting
@Parameter(defaultValue="false") protected boolean continueExecuting
Whether to continue executing remaining scripts when a script fails.
-
sourceEncoding
@Parameter(defaultValue="${project.build.sourceEncoding}") protected java.lang.String sourceEncoding
The encoding of script files.- Since:
- 1.0-beta-2
-
skipScriptExecution
@Parameter(defaultValue="false") protected boolean skipScriptExecution
Flag to allow script execution to be skipped.- Since:
- 1.9.1
-
-
Method Detail
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionException
Executes this mojo.- Throws:
org.apache.maven.plugin.MojoExecutionException
- If an unexpected problem occurs (causes a "BUILD ERROR" message to be displayed)
-
doExecute
protected void doExecute() throws org.apache.maven.plugin.MojoExecutionException
Does the actual execution.- Throws:
org.apache.maven.plugin.MojoExecutionException
- If an unexpected problem occurs (causes a "BUILD ERROR" message to be displayed)
-
setupShell
protected java.lang.Object setupShell(java.lang.Class<?> groovyShellClass) throws java.lang.reflect.InvocationTargetException, java.lang.IllegalAccessException, java.lang.InstantiationException, java.lang.ClassNotFoundException
Instantiates a new groovy.lang.GroovyShell object.- Parameters:
groovyShellClass
- the groovy.lang.GroovyShell class- Returns:
- a new groovy.lang.GroovyShell object
- Throws:
java.lang.reflect.InvocationTargetException
- when a reflection invocation needed for shell configuration cannot be completedjava.lang.IllegalAccessException
- when a method needed for shell configuration cannot be accessedjava.lang.InstantiationException
- when a class needed for shell configuration cannot be instantiatedjava.lang.ClassNotFoundException
- when a class needed for shell configuration cannot be found
-
executeScripts
protected void executeScripts(java.lang.Class<?> groovyShellClass, java.lang.Object shell) throws java.lang.reflect.InvocationTargetException, java.lang.IllegalAccessException, org.apache.maven.plugin.MojoExecutionException
Executes the configured scripts.- Parameters:
groovyShellClass
- the groovy.lang.GroovyShell classshell
- a groovy.lag.GroovyShell object- Throws:
java.lang.reflect.InvocationTargetException
- when a reflection invocation needed for script execution cannot be completedjava.lang.IllegalAccessException
- when a method needed for script execution cannot be accessedorg.apache.maven.plugin.MojoExecutionException
- when an exception occurred during script execution (causes a "BUILD ERROR" message to be displayed)
-
executeScriptFromUrl
protected void executeScriptFromUrl(java.lang.Class<?> groovyShellClass, java.lang.Object shell, java.lang.String script) throws java.io.IOException, java.lang.reflect.InvocationTargetException, java.lang.IllegalAccessException
Executes a script at a URL location.- Parameters:
groovyShellClass
- the GroovyShell classshell
- a groovy.lag.GroovyShell objectscript
- the script URL to execute- Throws:
java.io.IOException
- when the stream can't be opened on the URLjava.lang.reflect.InvocationTargetException
- when a reflection invocation needed for script execution cannot be completedjava.lang.IllegalAccessException
- when a method needed for script execution cannot be accessed
-
-