Class ApiRunner

java.lang.Object
org.apache.maven.impl.standalone.ApiRunner

public class ApiRunner extends Object
Provides functionality for running Maven API in a standalone mode.

This class serves as the main entry point for executing Maven operations outside of the standard Maven build environment. It provides methods for creating and managing Maven sessions in a simplified context, primarily for testing and specialized execution scenarios.

Example usage:

 Session session = ApiRunner.createSession();
 // Use session for Maven operations
 

The standalone mode provides a subset of Maven's functionality, with some features being unavailable or simplified. Operations not supported in standalone mode will throw UnsupportedInStandaloneModeException.

Since:
4.0.0
  • Constructor Details

    • ApiRunner

      public ApiRunner()
  • Method Details

    • createSession

      public static Session createSession()
      Creates a new Maven session with default configuration.
      Returns:
      a new Session instance
    • createSession

      public static Session createSession(Consumer<Injector> injectorConsumer)
      Creates a new Maven session with custom injector configuration.
      Parameters:
      injectorConsumer - consumer function to customize the injector
      Returns:
      a new Session instance
    • createSession

      public static Session createSession(Consumer<Injector> injectorConsumer, Path localRepo)
      Creates a new Maven session with custom injector configuration and local repository path.
      Parameters:
      injectorConsumer - consumer function to customize the injector
      localRepo - path to the local repository
      Returns:
      a new Session instance