Class MavenCommandLineExecutor

All Implemented Interfaces:
Runnable, MavenExecutor, org.openide.util.Cancellable

public class MavenCommandLineExecutor extends AbstractMavenExecutor
support for executing maven, externally on the command line. Since 2/1.144, the LateBoundPrerequisitesChecker registered in Maven projects for JAR packaging by default supports ExplicitProcessParameters API. The caller of the execute-type action can request to append or replace VM or user application parameters. The parameters recorded in the POM.xml or NetBeans action mappings are augmented according to that instructions:
  • launcherArgs are mapped to VM arguments (precede main class name)
  • args are mapped to user application arguments (after main class name)
VM parameters injected by StartupExtender API are not affected by this feature.

Example use:

// get action provider:
ActionProvider projectActionProvider = prj.getLookup().lookup(ActionProvider.class);

// create explicit additional parameters instruction:
ExplicitProcessParameters params = ExplicitProcessParameters.builder().
        launcherArg("-DvmArg2=2").
        arg("paramY").
        build();
// pass explicit parameters to the Run action:
projectActionProvider.invokeAction(ActionProvider.COMMAND_RUN, Lookups.fixed(params));
The example will append -DvmArg2=2 to VM arguments and replaces all user program arguments with "paramY". Append mode can be controlled using ExplicitProcessParameters.Builder.replaceArgs(boolean) or ExplicitProcessParameters.Builder.replaceLauncherArgs(boolean).
  • Constructor Details

  • Method Details

    • executeMaven

      public static org.openide.execution.ExecutorTask executeMaven(RunConfig config, org.openide.windows.InputOutput io, AbstractMavenExecutor.TabContext tc)
      Execute maven build in NetBeans execution engine. Most callers should rather use run() as this variant does no (non-late-bound) prerequisite checks. It is mostly suitable for cases where you need full control by the caller over the config, or want to rerun a previous execution.
      Parameters:
      config -
      io - null or InputOutput to reuse for output of the execution
      tc - tab context to use or null
      Returns:
      Since:
      2.113
    • run

      public void run()
      not to be called directly.. use execute();
    • cancel

      public boolean cancel()