Apache Maven Invoker

In many cases, tools (including Maven itself) may want to fire off a Maven build in a clean environment. Why? Perhaps you want to avoid polluting the current system environment with side-effects produced by Maven plugins. Maybe you want to run the build from a different working directory than the current ${user.dir}. Maybe you want to retain the ability to surgically kill one of many Maven builds if it hangs for some reason.

This API is concerned with firing a Maven build in a new JVM. It accomplishes its task by building up a conventional Maven command line from options given in the current request, along with those global options specified in the invoker itself. Once it has the command line, the invoker will execute it, and capture the resulting exit code or any exception thrown to signal a failure to execute. Input/output control can be specified using an InputStream and up to two InvocationOutputHandlers.

Features

  • Tracking of exit code and exception resulting from an invocation
  • Global Options:
    • Maven-Home Location (location of Maven application directory)
    • Local Repository Location
    • API Logger
    • Maven Executable
  • Request Options:
    • Global Checksum Policy (fail/warn, global across defined repositories)
    • Local Repository Location
    • Project Base Directory
    • POM File
    • POM File-Name (used in conjunction with Base Directory)
    • Interactive/Batch Mode (determines whether Maven prompts for input)
    • Offline Mode
    • Update-Snapshots Flag
    • Debug Flag (show debug-level output)
    • Quiet Flag (only show errors)
    • Show-Errors Flag (show exception stacktraces, but not full debug output)
    • No-Transfer-Progress Flag (Do not display transfer progress when downloading or uploading)
    • Inherit-Shell-Environment Flag (inherit envars from the shell used to start the current JVM)
    • Reactor-Failure Behavior (fail-at-end, fail-never, etc.)
    • Input/Output Handlers
    • Build Properties (-D switches)
    • Build Goals
    • Settings Location (settings.xml file path)
    • Threadcount ( since Maven3 with -T )
    • Toolchains location ( since Maven3 with -t )
    • Additional raw cli options at the start or the end of command line