Class 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 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

      • scripts

        @Parameter(required=true)
        protected String[] scripts
        Groovy scripts to run (in order). Can be an actual Groovy script or a URL to 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 sourceEncoding
        The encoding of script files.
        Since:
        1.0-beta-2
    • Constructor Detail

      • ExecuteMojo

        public ExecuteMojo()
    • Method Detail

      • execute

        public void execute()
                     throws org.apache.maven.plugin.MojoExecutionException,
                            org.apache.maven.plugin.MojoFailureException
        Executes this mojo.
        Throws:
        org.apache.maven.plugin.MojoExecutionException - If an unexpected problem occurs. Throwing this exception causes a "BUILD ERROR" message to be displayed
        org.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.MojoFailureException
        Does the actual execution.
        Throws:
        org.apache.maven.plugin.MojoExecutionException - If an unexpected problem occurs. Throwing this exception causes a "BUILD ERROR" message to be displayed
        org.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
      • 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 class
        shell - the shell to use for script execution
        Throws:
        IllegalAccessException - when a method needed for script execution cannot be accessed
        InvocationTargetException - when a reflection invocation needed for script execution cannot be completed
        org.apache.maven.plugin.MojoExecutionException - when an error occurs during script execution