Class ApiRunner
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, suitable for tools, IDE integrations, and specialized execution scenarios.
The standalone session reads and applies the user's settings.xml including:
- Local repository location
- Server authentication (username, password, private key)
- Proxy configuration
- Mirror configuration
- Repository definitions from active profiles
- Offline mode
It also loads maven-system.properties from the Maven configuration directory
(${maven.home}/conf or as configured via maven.installation.conf/maven.conf)
and from the user's Maven home (~/.m2/), merging both into the session's system properties.
User properties are loaded from ~/.m2/maven-user.properties and exposed via
ProtoSession.getUserProperties().
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumControls how the standalone session handles settings encryption/decryption. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic SessionCreates a new Maven session with default configuration.static SessioncreateSession(Consumer<Injector> injectorConsumer) Creates a new Maven session with custom injector configuration.static SessioncreateSession(Consumer<Injector> injectorConsumer, Path localRepo) Creates a new Maven session with custom injector configuration and local repository path.static SessioncreateSession(Consumer<Injector> injectorConsumer, Path localRepo, ApiRunner.SecurityMode securityMode) Creates a new Maven session with custom injector configuration, local repository path, and security mode.
-
Constructor Details
-
ApiRunner
public ApiRunner()
-
-
Method Details
-
createSession
-
createSession
-
createSession
Creates a new Maven session with custom injector configuration and local repository path.- Parameters:
injectorConsumer- consumer function to customize the injectorlocalRepo- path to the local repository- Returns:
- a new
Sessioninstance
-
createSession
public static Session createSession(Consumer<Injector> injectorConsumer, Path localRepo, ApiRunner.SecurityMode securityMode) Creates a new Maven session with custom injector configuration, local repository path, and security mode.- Parameters:
injectorConsumer- consumer function to customize the injectorlocalRepo- path to the local repositorysecurityMode- controls how encrypted passwords in settings are handled- Returns:
- a new
Sessioninstance
-