Class ToolRunner


  • public class ToolRunner
    extends java.lang.Object
    Runner for external tools.
    • Constructor Summary

      Constructors 
      Constructor Description
      ToolRunner​(java.io.File tool)
      Creates a runner for a tool.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      ToolRunner arg​(java.lang.Object... args)
      Adds arguments.
      void clear()
      Clears arguments and results.
      int getErrCode()
      Gets the error code.
      java.util.List<java.lang.String> getErrors()
      Gets the standard error output.
      java.lang.String getErrorsAsString()
      Gets the standard error output.
      java.util.List<java.lang.String> getOutput()
      Gets the standard output.
      java.lang.String getOutputAsString()
      Gets the standard output.
      ToolRunner run()
      Runs the tool.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • ToolRunner

        public ToolRunner​(java.io.File tool)
                   throws org.apache.maven.plugin.MojoExecutionException
        Creates a runner for a tool.
        Parameters:
        tool - the tool
        Throws:
        org.apache.maven.plugin.MojoExecutionException - if tool not found or not executable
    • Method Detail

      • arg

        public ToolRunner arg​(java.lang.Object... args)
        Adds arguments.
        Parameters:
        args - the arguments
        Returns:
        this runner
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • run

        public ToolRunner run()
                       throws org.apache.maven.plugin.MojoExecutionException
        Runs the tool.
        Returns:
        this runner
        Throws:
        org.apache.maven.plugin.MojoExecutionException - if running the tool failed
      • getOutput

        public java.util.List<java.lang.String> getOutput()
                                                   throws org.apache.maven.plugin.MojoExecutionException
        Gets the standard output.
        Returns:
        the output lines, never null
        Throws:
        org.apache.maven.plugin.MojoExecutionException - if run method not invoked
      • getOutputAsString

        public java.lang.String getOutputAsString()
                                           throws org.apache.maven.plugin.MojoExecutionException
        Gets the standard output.
        Returns:
        the output, never null
        Throws:
        org.apache.maven.plugin.MojoExecutionException - if run method not invoked
      • getErrors

        public java.util.List<java.lang.String> getErrors()
                                                   throws org.apache.maven.plugin.MojoExecutionException
        Gets the standard error output.
        Returns:
        the error lines, never null
        Throws:
        org.apache.maven.plugin.MojoExecutionException - if run method not invoked
      • getErrorsAsString

        public java.lang.String getErrorsAsString()
                                           throws org.apache.maven.plugin.MojoExecutionException
        Gets the standard error output.
        Returns:
        the errors, never null
        Throws:
        org.apache.maven.plugin.MojoExecutionException - if run method not invoked
      • getErrCode

        public int getErrCode()
                       throws org.apache.maven.plugin.MojoExecutionException
        Gets the error code.
        Returns:
        the error, 0 if ok
        Throws:
        org.apache.maven.plugin.MojoExecutionException - if run method not invoked
      • clear

        public void clear()
        Clears arguments and results.