Class 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
    Author:
    Keegan Witt
    • Field Detail

      • GROOVY_1_7_0

        protected static final Version GROOVY_1_7_0
        Groovy 1.7.0 version.
      • scripts

        @Parameter(required=true)
        protected String[] scripts
        Groovy scripts to run (in order). Can be a script body, a URL 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 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
    • Constructor Detail

      • ExecuteMojo

        public ExecuteMojo()
    • 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)
      • executeScripts

        protected void executeScripts​(Class<?> groovyShellClass,
                                      Object shell)
                               throws InvocationTargetException,
                                      IllegalAccessException,
                                      org.apache.maven.plugin.MojoExecutionException
        Executes the configured scripts.
        Parameters:
        groovyShellClass - the groovy.lang.GroovyShell class
        shell - a groovy.lag.GroovyShell object
        Throws:
        InvocationTargetException - when a reflection invocation needed for script execution cannot be completed
        IllegalAccessException - when a method needed for script execution cannot be accessed
        org.apache.maven.plugin.MojoExecutionException - when an exception occurred during script execution (causes a "BUILD ERROR" message to be displayed)