Class ConsoleMojo

java.lang.Object
org.apache.maven.plugin.AbstractMojo
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

@Mojo(name="console", requiresDependencyResolution=TEST) public class ConsoleMojo extends AbstractToolsMojo
Launches a Groovy console window 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). Note that using the ant property requires Java 8, as the included Ant version was compiled for Java 8.
Since:
1.1
Author:
Keegan Witt
  • Field Details

    • consoleScript

      @Parameter(property="consoleScript") protected String consoleScript
      Script file to load into console. Can also be a project property referring to a file.
      Since:
      1.10.1
  • Constructor Details

    • ConsoleMojo

      public ConsoleMojo()
  • Method Details

    • 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 (causes a "BUILD ERROR" message to be displayed)
      org.apache.maven.plugin.MojoFailureException - If unable to await console exit
    • loadScript

      protected void loadScript(Class<?> consoleClass, Object console) throws InvocationTargetException, IllegalAccessException
      Throws:
      InvocationTargetException
      IllegalAccessException
    • setupConsole

      protected Object setupConsole(Class<?> consoleClass, Class<?> bindingClass) throws InvocationTargetException, IllegalAccessException, InstantiationException
      Instantiates a groovy.ui.Console object.
      Parameters:
      consoleClass - the groovy.ui.Console class to use
      bindingClass - the groovy.lang.Binding class to use
      Returns:
      a new groovy.ui.Console object
      Throws:
      InvocationTargetException - when a reflection invocation needed for instantiating a console object cannot be completed
      IllegalAccessException - when a method needed for instantiating a console object cannot be accessed
      InstantiationException - when a class needed for instantiating a console object cannot be instantiated
    • bindAntBuilder

      protected void bindAntBuilder(Class<?> consoleClass, Class<?> bindingClass, Object console) throws ClassNotFoundException, IllegalAccessException, InvocationTargetException
      Binds a new AntBuilder to the project properties.
      Parameters:
      consoleClass - the groovy.ui.Console class to use
      bindingClass - the groovy.lang.Binding class to use
      console - the groovy.ui.Console object to use
      Throws:
      ClassNotFoundException - when a class needed for binding an AntBuilder object cannot be found
      IllegalAccessException - when a method needed for binding an AntBuilder object cannot be accessed
      InvocationTargetException - when a reflection invocation needed for binding an AntBuilder object cannot be completed
    • waitForConsoleClose

      protected void waitForConsoleClose() throws org.apache.maven.plugin.MojoFailureException
      Waits for the console in use to be closed.
      Throws:
      org.apache.maven.plugin.MojoFailureException - if the execution was interrupted while running or it was unable to find the console thread to wait on