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 Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.apache.maven.api.Session
    Creates a new Maven session with default configuration.
    static org.apache.maven.api.Session
    createSession(Consumer<org.apache.maven.di.Injector> injectorConsumer)
    Creates a new Maven session with custom injector configuration.
    static org.apache.maven.api.Session
    createSession(Consumer<org.apache.maven.di.Injector> injectorConsumer, Path localRepo)
    Creates a new Maven session with custom injector configuration and local repository path.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ApiRunner

      public ApiRunner()
  • Method Details

    • createSession

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

      public static org.apache.maven.api.Session createSession(Consumer<org.apache.maven.di.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 org.apache.maven.api.Session createSession(Consumer<org.apache.maven.di.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