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, configurator="include-project-test-dependencies", threadSafe=true) public class ExecuteMojo extends AbstractToolsMojoExecutes 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
- Author:
- Keegan Witt
-
-
Field Summary
Fields Modifier and Type Field Description protected booleancontinueExecutingWhether to continue executing remaining scripts when a script fails.protected String[]scriptsGroovy scripts to run (in order).protected StringsourceEncodingThe encoding of script files.-
Fields inherited from class org.codehaus.gmavenplus.mojo.AbstractToolsMojo
allowSystemExits, bindPropertiesToSeparateVariables, 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_SOURCES_PATTERN, minGroovyVersion, mojoExecution, pluginArtifacts, project, session, skipTests
-
-
Constructor Summary
Constructors Constructor Description ExecuteMojo()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddoExecute()Does the actual execution.voidexecute()Executes this mojo.protected voidexecuteScripts(Class<?> groovyShellClass, Object shell)Executes the scripts using the GroovyShell.protected ObjectsetupShell(Class<?> groovyShellClass)Creates the GroovyShell shell to use to execute scripts.-
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, isJavaSupportIndy, isJavaSupportParameters, logPluginClasspath
-
-
-
-
Field Detail
-
scripts
@Parameter(required=true) protected String[] scripts
Groovy scripts to run (in order). Can be an actual Groovy script or aURLto a Groovy script (local or remote).
-
continueExecuting
@Parameter(defaultValue="false") protected boolean continueExecuting
Whether to continue executing remaining scripts when a script fails.
-
sourceEncoding
@Parameter(defaultValue="${project.build.sourceEncoding}") protected String sourceEncodingThe encoding of script files.- Since:
- 1.0-beta-2
-
-
Method Detail
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureExceptionExecutes this mojo.- Throws:
org.apache.maven.plugin.MojoExecutionException- If an unexpected problem occurs. Throwing this exception causes a "BUILD ERROR" message to be displayedorg.apache.maven.plugin.MojoFailureException- If an expected problem (such as a compilation failure) occurs. Throwing this exception causes a "BUILD FAILURE" message to be displayed
-
doExecute
protected void doExecute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureExceptionDoes the actual execution.- Throws:
org.apache.maven.plugin.MojoExecutionException- If an unexpected problem occurs. Throwing this exception causes a "BUILD ERROR" message to be displayedorg.apache.maven.plugin.MojoFailureException- If an expected problem (such as a invocation failure) occurs. Throwing this exception causes a "BUILD FAILURE" message to be displayed
-
setupShell
protected Object setupShell(Class<?> groovyShellClass) throws InvocationTargetException, IllegalAccessException, InstantiationException, ClassNotFoundException
Creates the GroovyShell shell to use to execute scripts.- Parameters:
groovyShellClass- the GroovyShell class- Returns:
- the GroovyShell shell to use to execute scripts
- Throws:
InstantiationException- when a class needed for script execution cannot be instantiatedIllegalAccessException- when a method needed for script execution cannot be accessedInvocationTargetException- when a reflection invocation needed for script execution cannot be completedClassNotFoundException
-
executeScripts
protected void executeScripts(Class<?> groovyShellClass, Object shell) throws InvocationTargetException, IllegalAccessException, org.apache.maven.plugin.MojoExecutionException
Executes the scripts using the GroovyShell.- Parameters:
groovyShellClass- the GroovyShell classshell- the shell to use for script execution- Throws:
IllegalAccessException- when a method needed for script execution cannot be accessedInvocationTargetException- when a reflection invocation needed for script execution cannot be completedorg.apache.maven.plugin.MojoExecutionException- when an error occurs during script execution
-
-