### Build and Install Maven Extension
Source: https://github.com/apache/maven/blob/master/its/core-it-suite/src/test/resources/mng-8572-di-type-handler/README.md
Commands to build and install the custom Maven extension plugin.
```bash
cd extension
mvn install
```
--------------------------------
### Install Dummy Artifact
Source: https://github.com/apache/maven/blob/master/its/core-it-suite/src/test/resources/mng-8572-di-type-handler/README.md
Command to install the dummy artifact required for the test project.
```bash
cd test
./install-dummy.sh
```
--------------------------------
### Bootstrap Apache Maven
Source: https://github.com/apache/maven/blob/master/README.md
Command to build and install the Maven distribution to a specified directory. Requires Java 17+ and an existing Maven 3.9.0+ installation.
```bash
mvn -DdistributionTargetDir="$HOME/app/maven/apache-maven-4.1.x-SNAPSHOT" clean package
```
--------------------------------
### Configure session start time
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/session.md
Sets the start time for the session using an Instant object.
```java
Builder withStartTime(@Nonnull Instant startTime)
```
--------------------------------
### Example Configuration Merging Logic
Source: https://github.com/apache/maven/blob/master/src/site/markdown/cache-configuration.md
Demonstrates how multiple selectors are merged to determine the final configuration.
```text
ModelBuilderRequest { scope: session } # Base: sets scope
* ModelBuilderRequest { ref: hard } # Adds ref type
ModelBuildRequest ModelBuilderRequest { ref: soft } # Overrides ref for specific parent
```
--------------------------------
### Retrieve Session Start Time
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/session.md
Get the session start time as an Instant.
```java
@Nonnull
Instant getStartTime()
```
--------------------------------
### Example usage of ProjectBuilder
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/services.md
Demonstrates building a project by creating a request and invoking the service from the session.
```java
ProjectBuilderRequest request = ProjectBuilderRequest.build(session, pomPath);
ProjectBuilderResult result = session.getService(ProjectBuilder.class).build(request);
Project project = result.getProject();
```
--------------------------------
### ArtifactInstaller.install
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/services.md
Installs artifacts to the local repository using the provided request object.
```APIDOC
## void install(ArtifactInstallerRequest request)
### Description
Installs artifacts to the local repository.
### Parameters
- **request** (ArtifactInstallerRequest) - Required - Installation request with artifacts
### Throws
- **ArtifactInstallerException** - If installation fails
```
--------------------------------
### Define Maven Toolchains
Source: https://github.com/apache/maven/blob/master/_autodocs/configuration.md
Example configuration for a JDK toolchain in the ~/.m2/toolchains.xml file.
```xml
jdk11/usr/lib/jvm/java-11-openjdk
```
--------------------------------
### Custom Mojo Implementation
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/plugin-development.md
A complete example of a Mojo implementation demonstrating parameter injection, session services, and dependency processing.
```java
@Mojo(
name = "process-artifacts",
defaultPhase = LifecyclePhase.PROCESS_RESOURCES,
requiresDependencyCollection = ResolutionScope.COMPILE
)
public class ProcessArtifactsMojo implements Mojo {
@Parameter(defaultValue = "${session}", readonly = true)
private Session session;
@Parameter(defaultValue = "${project}", readonly = true)
private Project project;
@Parameter(defaultValue = "${log}", readonly = true)
private Log log;
@Parameter(
name = "outputDirectory",
defaultValue = "${project.build.directory}/artifacts",
required = false
)
private File outputDirectory;
@Parameter(
name = "skip",
property = "process.artifacts.skip",
defaultValue = "false"
)
private boolean skip;
@Override
public void execute() throws Exception {
if (skip) {
log.info("Skipping artifact processing");
return;
}
log.info("Processing artifacts for: " + project.getArtifactId());
try {
// Resolve project dependencies
Project proj = project;
List deps = proj.getDependencies();
log.debug("Found " + deps.size() + " dependencies");
// Get artifact manager
ArtifactManager artifactMgr = session.getService(ArtifactManager.class);
// Process each artifact
for (Dependency dep : deps) {
Path artifactPath = artifactMgr.getPath((Artifact) dep);
log.info("Processing: " + artifactPath);
// Process artifact...
}
log.info("Artifact processing complete");
} catch (Exception e) {
log.error("Error processing artifacts", e);
throw e;
}
}
}
```
--------------------------------
### Build Maven Extension
Source: https://github.com/apache/maven/blob/master/its/core-it-suite/src/test/resources/mng-8461/extension/README.md
Execute this command to build the Maven extension locally. Ensure you have Maven wrapper installed.
```bash
./mvnw clean install
```
--------------------------------
### Retrieve Top Directory
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/session.md
Get the directory of the topmost project being built.
```java
@Nonnull
Path getTopDirectory()
```
```java
Path topDir = session.getTopDirectory();
Path pomFile = topDir.resolve("pom.xml");
```
--------------------------------
### Get build configuration
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/project-and-build.md
Retrieves the effective build configuration for the project.
```java
@Nonnull
Build getBuild()
```
--------------------------------
### Site configuration directory structure
Source: https://github.com/apache/maven/blob/master/impl/maven-core/src/site/markdown/configuration-management.md
Represents the file layout for Maven site-level configuration within the installation directory.
```text
${maven.home}
|
+--- maven.properties
```
--------------------------------
### Maven 4.0.0-beta-5 Dependency Tree Output
Source: https://github.com/apache/maven/blob/master/its/core-it-suite/src/test/resources/mng-8347-transitive-dependency-manager/README.md
Example output showing transitive dependency management behavior in Maven 4.0.0-beta-5.
```text
$ mvn -V eu.maveniverse.maven.plugins:toolbox:tree -Dmaven.repo.local.tail=local-repo
Apache Maven 4.0.0-beta-5 (6e78fcf6f5e76422c0eb358cd11f0c231ecafbad)
Maven home: /home/cstamas/.sdkman/candidates/maven/4.0.0-beta-5
Java version: 21.0.4, vendor: Eclipse Adoptium, runtime: /home/cstamas/.sdkman/candidates/java/21.0.4-tem
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "6.11.4-201.fc40.x86_64", arch: "amd64", family: "unix"
[WARNING] Unable to find the root directory. Create a .mvn directory in the root directory or add the root="true" attribute on the root project's model to identify it.
[WARNING] Pre-Maven 4 legacy encrypted password detected for server my-legacy-server - configure password encryption with the help of mvnenc to be compatible with Maven 4.
[WARNING] Pre-Maven 4 legacy encrypted password detected for server my-legacy-broken-server - configure password encryption with the help of mvnenc to be compatible with Maven 4.
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------------------------< org.apache.maven.it.mresolver614:root >-----------------------------------------
[INFO] Building root 1.0.0
[INFO] from pom.xml
[INFO] ---------------------------------------------------------[ jar ]----------------------------------------------------------
[INFO]
[INFO] --- toolbox:0.3.5:tree (default-cli) @ root ---
[INFO] org.apache.maven.it.mresolver614:root:jar:1.0.0
[INFO] ╰─org.apache.maven.it.mresolver614:level1:jar:1.0.0 [compile]
[INFO] ╰─org.apache.maven.it.mresolver614:level2:jar:1.0.0 [compile]
[INFO] ╰─org.apache.maven.it.mresolver614:level3:jar:1.0.1 [compile] (version managed from 1.0.0)
[INFO] ╰─org.apache.maven.it.mresolver614:level4:jar:1.0.1 [compile] (version managed from 1.0.0)
[INFO] ╰─org.apache.maven.it.mresolver614:level5:jar:1.0.2 [compile] (version managed from 1.0.0)
[INFO] ╰─org.apache.maven.it.mresolver614:level6:jar:1.0.2 [compile] (version managed from 1.0.0)
[INFO] --------------------------------------------------------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] --------------------------------------------------------------------------------------------------------------------------
[INFO] Total time: 0.285 s
[INFO] Finished at: 2024-10-24T19:21:10+02:00
```
--------------------------------
### Run Maven Core ITs with Specific Version
Source: https://github.com/apache/maven/blob/master/its/src/site/markdown/index.md
Downloads, unpacks, and tests a specific version of a previously installed or deployed Maven distribution.
```shell
mvn clean test -Prun-its -DmavenVersion=2.2.1
```
--------------------------------
### Define Maven Plugin Configuration
Source: https://github.com/apache/maven/blob/master/_autodocs/configuration.md
Example of configuring a Maven plugin within a POM file, specifically setting compiler source and target versions.
```xml
org.apache.maven.pluginsmaven-compiler-plugin3.11.01111UTF-8
```
--------------------------------
### Get Version String Representation
Source: https://github.com/apache/maven/blob/master/_autodocs/types.md
Returns the string representation of a version object.
```java
@Nonnull
@Override
String toString()
```
--------------------------------
### Maven 3.9.9 Dependency Tree Output
Source: https://github.com/apache/maven/blob/master/its/core-it-suite/src/test/resources/mng-8347-transitive-dependency-manager/README.md
Example output showing non-transitive dependency management behavior in Maven 3.9.9.
```text
$ mvn -V eu.maveniverse.maven.plugins:toolbox:tree -Dmaven.repo.local.tail=local-repo
Apache Maven 3.9.9 (8e8579a9e76f7d015ee5ec7bfcdc97d260186937)
Maven home: /home/cstamas/.sdkman/candidates/maven/3.9.9
Java version: 21.0.4, vendor: Eclipse Adoptium, runtime: /home/cstamas/.sdkman/candidates/java/21.0.4-tem
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "6.11.4-201.fc40.x86_64", arch: "amd64", family: "unix"
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------< org.apache.maven.it.mresolver614:root >----------------
[INFO] Building root 1.0.0
[INFO] from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- toolbox:0.3.5:tree (default-cli) @ root ---
[INFO] org.apache.maven.it.mresolver614:root:jar:1.0.0
[INFO] ╰─org.apache.maven.it.mresolver614:level1:jar:1.0.0 [compile]
[INFO] ╰─org.apache.maven.it.mresolver614:level2:jar:1.0.0 [compile]
[INFO] ╰─org.apache.maven.it.mresolver614:level3:jar:1.0.0 [compile]
[INFO] ╰─org.apache.maven.it.mresolver614:level4:jar:1.0.0 [compile]
[INFO] ╰─org.apache.maven.it.mresolver614:level5:jar:1.0.0 [compile]
[INFO] ╰─org.apache.maven.it.mresolver614:level6:jar:1.0.2 [compile] (version managed from 1.0.0)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.192 s
[INFO] Finished at: 2024-10-24T19:20:39+02:00
[INFO] ------------------------------------------------------------------------
$
```
--------------------------------
### Building a Project
Source: https://github.com/apache/maven/blob/master/_autodocs/MAVEN-API-REFERENCE.md
Illustrates how to build a project from a POM file path and access its metadata.
```java
ProjectBuilderRequest request = ProjectBuilderRequest.build(session, pomPath);
ProjectBuilderResult result = session.getService(ProjectBuilder.class).build(request);
Project project = result.getProject();
String groupId = project.getGroupId();
String artifactId = project.getArtifactId();
String version = project.getVersion();
```
--------------------------------
### Get Mirror Name
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/repositories-and-settings.md
Retrieves the descriptive name for the mirror.
```java
String getName()
```
--------------------------------
### Project Building
Source: https://github.com/apache/maven/blob/master/_autodocs/MAVEN-API-REFERENCE.md
Demonstrates how to build a Maven project from a POM file.
```APIDOC
## Project Building
### Description
Builds a project model from a given POM file path.
### Method
ProjectBuilder.build(ProjectBuilderRequest)
### Parameters
- **session** (Session) - The current Maven session.
- **pomPath** (Path) - The file path to the pom.xml.
### Example
```java
ProjectBuilderRequest request = ProjectBuilderRequest.build(session, pomPath);
ProjectBuilderResult result = session.getService(ProjectBuilder.class).build(request);
Project project = result.getProject();
```
```
--------------------------------
### Get Mirror URL
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/repositories-and-settings.md
Retrieves the URL of the mirror repository.
```java
String getUrl()
```
--------------------------------
### Build a Project using ProjectBuilder
Source: https://github.com/apache/maven/blob/master/_autodocs/README.txt
Demonstrates the standard workflow for building a project from a POM file using the Maven session and ProjectBuilder service.
```java
Session session = ...;
ProjectBuilder builder = session.getService(ProjectBuilder.class);
ProjectBuilderResult result = builder.build(session, pomPath);
Project project = result.getProject();
```
--------------------------------
### Get Server Password
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/repositories-and-settings.md
Retrieves the password for server authentication.
```java
String getPassword()
```
--------------------------------
### Get Server Username
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/repositories-and-settings.md
Retrieves the username for server authentication.
```java
String getUsername()
```
--------------------------------
### Configure Maven Session with ProtoSession Builder
Source: https://github.com/apache/maven/blob/master/_autodocs/configuration.md
Demonstrates initializing a Maven session using the ProtoSession builder with custom user and system properties.
```java
ProtoSession.Builder builder = ProtoSession.newBuilder()
.withUserProperties(Map.of(
"project.version", "1.0.0",
"skipTests", "true"
))
.withSystemProperties(System.getProperties())
.withStartTime(Instant.now())
.withTopDirectory(Paths.get("."))
.withRootDirectory(Paths.get("/project/root"));
ProtoSession session = builder.build();
```
--------------------------------
### Get project dependencies
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/project-and-build.md
Returns the resolved dependencies for the project.
```java
@Nonnull
List getDependencies()
```
--------------------------------
### Get Server Passphrase
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/repositories-and-settings.md
Retrieves the passphrase associated with the private key.
```java
String getPassphrase()
```
--------------------------------
### Get resolved version
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/version-management.md
Retrieves the resolved version from a VersionResolverResult instance.
```java
@Nonnull
Version getVersion()
```
--------------------------------
### Accessing Maven Services
Source: https://github.com/apache/maven/blob/master/_autodocs/MAVEN-API-REFERENCE.md
Demonstrates how to retrieve core Maven services from the current session.
```java
Session session = ...;
ArtifactResolver resolver = session.getService(ArtifactResolver.class);
ProjectBuilder builder = session.getService(ProjectBuilder.class);
DependencyResolver depResolver = session.getService(DependencyResolver.class);
```
--------------------------------
### Build a project from a file path
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/services.md
Provides a default method to build a project directly from a Path object.
```java
@Nonnull
default ProjectBuilderResult build(
@Nonnull Session session,
@Nonnull Path path)
throws ProjectBuilderException
```
--------------------------------
### Get Non-Proxy Hosts
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/repositories-and-settings.md
Retrieves a comma-separated list of hosts that should bypass the proxy.
```java
String getNonProxyHosts()
```
--------------------------------
### Build Maven Core and Run Integration Tests Script
Source: https://github.com/apache/maven/blob/master/its/README.md
Build Maven core using the `-PversionlessMavenDist` profile, then execute the integration tests using the provided shell script.
```bash
sh ./run-its.sh
```
--------------------------------
### Get Proxy Port
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/repositories-and-settings.md
Retrieves the port number used by the proxy server.
```java
int getPort()
```
--------------------------------
### Define Maven System Properties
Source: https://github.com/apache/maven/blob/master/impl/maven-core/src/site/markdown/configuration-management.md
Lists the default directory paths for Maven user configuration, home, and local repository.
```text
maven.user.config.dir (system,default=${user.home}/.m2)
maven.home (system,user,default=${user.home}/m2)
maven.repo.local (system,user,default=${maven.user.config.dir}/repository)
```
--------------------------------
### Get Proxy Host
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/repositories-and-settings.md
Retrieves the hostname or IP address of the proxy server.
```java
String getHost()
```
--------------------------------
### Run Maven initialization commands
Source: https://github.com/apache/maven/blob/master/its/core-it-suite/src/test/resources/mng-2339/b/readme.txt
Execute these commands to verify that the -Dversion property overrides the POM version definition.
```bash
mvn clean initialize
```
```bash
mvn -Dversion=2 clean initialize
```
--------------------------------
### Get source roots
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/project-and-build.md
Returns a collection of all source roots associated with the project.
```java
@Nonnull
Collection getSourceRoots()
```
--------------------------------
### Version Parsing and Comparison
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/version-management.md
Demonstrates how to parse version strings into Version objects and compare them using the Session API.
```APIDOC
## Session.parseVersion(String version)
### Description
Parses a version string into a Version object for comparison.
### Method
Java Method
### Parameters
- **version** (String) - Required - The version string to parse (e.g., "1.0.0").
### Returns
- **Version** - An object representing the parsed version that implements Comparable.
```
--------------------------------
### Run Maven Integration Tests in Docker
Source: https://github.com/apache/maven/blob/master/its/environments/README.md
Commands to build a Docker image, run it interactively, clone the Maven repository, and execute integration tests. Ensure the Maven distribution path is correctly set.
```bash
$ID=$(docker build -q .)
docker run --rm -t -i $ID bash
$cd $HOME
git clone https://gitbox.apache.org/repos/asf/maven.git
( cd maven && mvn clean verify )
git clone https://gitbox.apache.org/repos/asf/maven-integration-testing.git
( cd maven-integration-testing && mvn clean install -Prun-its -Dmaven.repo.local=$HOME/work/repo -DmavenDistro=$HOME/maven/apache-maven/target/apache-maven-...-bin.zip )
```
--------------------------------
### Configure Basic Cache Settings
Source: https://github.com/apache/maven/blob/master/src/site/markdown/cache-configuration.md
Apply a simple configuration for a specific request type.
```bash
mvn clean install -Dmaven.cache.config="ModelBuilderRequest { scope: session, ref: hard }"
```
--------------------------------
### Get Server ID
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/repositories-and-settings.md
Retrieves the server ID, which must match a repository ID.
```java
String getId()
```
--------------------------------
### ProtoSession.getSystemProperties()
Source: https://github.com/apache/maven/blob/master/_autodocs/configuration.md
Retrieves system properties, including environment variables prefixed with 'env.'.
```APIDOC
## Method: ProtoSession.getSystemProperties()
### Description
Returns a map of system properties available to the session. Environment variables are accessible via this map using the 'env.' prefix.
### Signature
Map getSystemProperties()
### Returns
- **Map** - A map containing system properties and environment variables.
```
--------------------------------
### Retrieve Root Directory
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/session.md
Get the root directory of the session, determined from the topmost project.
```java
@Nonnull
Path getRootDirectory()
```
--------------------------------
### Get project properties
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/project-and-build.md
Retrieves project properties defined within the POM file.
```java
@Nonnull
Map getProperties()
```
--------------------------------
### ProjectBuilder.build(Session, Path)
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/services.md
Builds a project from a specified file path.
```APIDOC
## ProjectBuilder.build(Session, Path)
### Description
Builds a project from a file path.
### Parameters
- **session** (Session) - Required - Maven session
- **path** (Path) - Required - Path to pom.xml
### Returns
- **ProjectBuilderResult** - Built project
```
--------------------------------
### Resolving a single artifact
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/services.md
Example of resolving an artifact using coordinates and the ArtifactResolver service.
```java
Session session = ...;
ArtifactCoordinates coords = session.createArtifactCoordinates(
"org.apache.maven", "maven-core", "jar", "", "4.0.0"
);
ArtifactResolverRequest request = ArtifactResolverRequest.build(session, coords);
ArtifactResolverResult result = session.getService(ArtifactResolver.class).resolve(request);
DownloadedArtifact artifact = result.getArtifacts().get(0);
```
--------------------------------
### Parse and Compare Versions
Source: https://github.com/apache/maven/blob/master/_autodocs/types.md
Demonstrates parsing a version string and comparing two version objects.
```java
Version version = session.parseVersion("1.0.0");
String versionStr = version.toString(); // "1.0.0"
// Version comparison
Version v1 = session.parseVersion("1.0.0");
Version v2 = session.parseVersion("2.0.0");
if (v1.compareTo(v2) < 0) {
System.out.println("v1 is older");
}
```
--------------------------------
### Get Mirror Pattern
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/repositories-and-settings.md
Retrieves the repository ID pattern that this mirror covers, supporting wildcards.
```java
String getMirrorOf()
```
```java
Mirror mirror = ...;
String mirrorOf = mirror.getMirrorOf();
if (mirrorOf.equals("*")) {
// Mirrors all repositories
} else if (mirrorOf.contains("external")) {
// Mirrors external repositories only
}
```
--------------------------------
### Run Maven Integration Tests with Vagrant
Source: https://github.com/apache/maven/blob/master/its/environments/README.md
Commands for Vagrant environments to SSH into a machine, clone the Maven repository, and execute integration tests. This is for non-Linux systems and requires a Vagrant provider like Virtualbox.
```bash
$vagrant ssh
$git clone https://gitbox.apache.org/repos/asf/maven.git
( cd maven && mvn clean verify )
$git clone https://gitbox.apache.org/repos/asf/maven-integration-testing.git
( cd maven-integration-testing && mvn clean install -Prun-its -Dmaven.repo.local=$HOME/work/repo -DmavenDistro=$HOME/maven/apache-maven/target/apache-maven-...-bin.zip )
```
--------------------------------
### Get Proxy Protocol
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/repositories-and-settings.md
Retrieves the protocol used by the proxy, such as http, https, socks4, or socks5.
```java
String getProtocol()
```
--------------------------------
### Parse and Compare Versions in Java
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/version-management.md
Use the session to parse version strings into comparable objects for logical version ordering.
```java
Session session = ...;
// Parse versions
Version v1 = session.parseVersion("1.0.0");
Version v2 = session.parseVersion("1.0.1");
Version v3 = session.parseVersion("2.0.0");
// Compare
if (v1.compareTo(v2) < 0) {
System.out.println("v1 is older than v2");
}
```
--------------------------------
### Retrieve Repository Port
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/repositories-and-settings.md
Get the port number, handling the case where the default port is used.
```java
int port = repo.getPort();
if (port == -1) {
// Use default port for protocol
} else {
// Use specified port
}
```
--------------------------------
### Advanced benchmark options
Source: https://github.com/apache/maven/blob/master/impl/maven-xml/BENCHMARKS.md
Commands for generating JSON reports and profiling memory or execution using async profiler.
```bash
mvn test-compile exec:java -Dexec.mainClass="org.openjdk.jmh.Main" \
-Dexec.classpathScope=test \
-Dexec.args="-rf json -rff benchmark-results.json org.apache.maven.internal.xml.*Benchmark" \
-pl impl/maven-xml
```
```bash
mvn test-compile exec:java -Dexec.mainClass="org.openjdk.jmh.Main" \
-Dexec.classpathScope=test \
-Dexec.args="-prof gc XmlPlexusConfigurationMemoryBenchmark" \
-pl impl/maven-xml
```
```bash
mvn test-compile exec:java -Dexec.mainClass="org.openjdk.jmh.Main" \
-Dexec.classpathScope=test \
-Dexec.args="-prof async:output=flamegraph XmlPlexusConfigurationBenchmark" \
-pl impl/maven-xml
```
--------------------------------
### Writing a Mojo Plugin
Source: https://github.com/apache/maven/blob/master/_autodocs/MAVEN-API-REFERENCE.md
Defines a basic Mojo implementation with injected session, project, and log parameters.
```java
@Mojo(
name = "my-goal",
defaultPhase = LifecyclePhase.PROCESS_RESOURCES,
requiresDependencyCollection = ResolutionScope.COMPILE
)
public class MyMojo implements Mojo {
@Parameter(defaultValue = "${session}", readonly = true)
private Session session;
@Parameter(defaultValue = "${project}", readonly = true)
private Project project;
@Parameter(defaultValue = "${log}", readonly = true)
private Log log;
@Override
public void execute() throws Exception {
log.info("Processing: " + project.getArtifactId());
// Perform work...
}
}
```
--------------------------------
### Retrieve Build Plugins
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/project-and-build.md
Returns the list of plugins configured for the build.
```java
List getPlugins()
```
--------------------------------
### Run specific benchmarks
Source: https://github.com/apache/maven/blob/master/impl/maven-xml/BENCHMARKS.md
Commands to isolate testing for constructor performance, memory allocation, and thread safety.
```bash
mvn test-compile exec:java -Dexec.mainClass="org.openjdk.jmh.Main" \
-Dexec.classpathScope=test \
-Dexec.args="XmlPlexusConfigurationBenchmark.constructor.*" \
-pl impl/maven-xml
```
```bash
mvn test-compile exec:java -Dexec.mainClass="org.openjdk.jmh.Main" \
-Dexec.classpathScope=test \
-Dexec.args="XmlPlexusConfigurationMemoryBenchmark" \
-pl impl/maven-xml
```
```bash
mvn test-compile exec:java -Dexec.mainClass="org.openjdk.jmh.Main" \
-Dexec.classpathScope=test \
-Dexec.args="XmlPlexusConfigurationConcurrencyBenchmark" \
-pl impl/maven-xml
```
--------------------------------
### Get versions from range result
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/version-management.md
Accesses the list of available versions or the highest version from a resolution result.
```java
@Nonnull
List getVersions()
```
```java
@Nonnull
Version getHighestVersion()
```
--------------------------------
### Mojo Configuration Parameters
Source: https://github.com/apache/maven/blob/master/impl/maven-core/lifecycle-executor.txt
List of available parameters for configuring Maven Mojo goals.
```APIDOC
## Mojo Configuration Parameters
### Description
Defines the configuration parameters available for a Maven Mojo, used to validate POM settings and apply default values during plugin execution.
### Parameters
- **appendedResourcesDirectory** (java.io.File) - Optional - Directory for appended resources.
- **attached** (boolean) - Optional - Whether the artifact is attached.
- **excludeArtifactIds** (java.lang.String) - Optional - Artifact IDs to exclude.
- **excludeGroupIds** (java.lang.String) - Optional - Group IDs to exclude.
- **excludeScope** (java.lang.String) - Optional - Scope to exclude.
- **excludeTransitive** (boolean) - Optional - Whether to exclude transitive dependencies.
- **includeArtifactIds** (java.lang.String) - Optional - Artifact IDs to include.
- **includeGroupIds** (java.lang.String) - Optional - Group IDs to include.
- **includeScope** (java.lang.String) - Optional - Scope to include.
- **localRepository** (org.apache.maven.artifact.repository.ArtifactRepository) - Required - The local repository.
- **mavenSession** (org.apache.maven.execution.MavenSession) - Required - The Maven session.
- **outputDirectory** (java.io.File) - Optional - Output directory path.
- **project** (org.apache.maven.project.MavenProject) - Required - The current Maven project.
- **properties** (java.util.Map) - Optional - Configuration properties.
- **remoteArtifactRepositories** (java.util.List) - Required - List of remote artifact repositories.
- **repositories** (java.util.List) - Required - List of repositories.
- **resourceBundles** (java.util.List) - Required - List of resource bundles.
- **resources** (java.util.List) - Required - List of resources.
- **skip** (boolean) - Optional - Whether to skip the execution.
- **supplementalModels** (java.lang.String[]) - Optional - Array of supplemental models.
```
--------------------------------
### Get Server Private Key
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/repositories-and-settings.md
Retrieves the path to the private key file used for SSH authentication.
```java
String getPrivateKey()
```
--------------------------------
### Get transitive dependencies by scope
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/project-and-build.md
Retrieves transitive dependencies filtered by a specific PathScope such as COMPILE or RUNTIME.
```java
@Nonnull
List getTransitiveDependencies(PathScope scope)
```
--------------------------------
### Configure top project directory
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/session.md
Sets the top-level directory for the project.
```java
Builder withTopDirectory(@Nonnull Path topDirectory)
```
--------------------------------
### Collect dependencies from DependencyCoordinates
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/dependency-resolution.md
Builds a dependency graph starting from specific coordinates without downloading artifact files.
```java
@Nonnull
default DependencyResolverResult collect(
@Nonnull Session session,
@Nonnull DependencyCoordinates root,
@Nonnull PathScope scope)
```
```java
DependencyCoordinates root = session.createDependencyCoordinates(
"org.apache.maven",
"maven-core",
"jar",
"",
"4.0.0",
"compile"
);
DependencyResolverResult result = session.getService(DependencyResolver.class)
.collect(session, root, PathScope.COMPILE_RUNTIME);
Node root = result.getRoot();
List deps = root.getDependencies();
```
--------------------------------
### Dependency Resolution
Source: https://github.com/apache/maven/blob/master/_autodocs/MAVEN-API-REFERENCE.md
Demonstrates how to collect dependencies for a project.
```APIDOC
## Dependency Resolution
### Description
Collects dependencies for a project within a specific scope.
### Method
DependencyResolver.collect(DependencyResolverRequest)
### Parameters
- **session** (Session) - The current Maven session.
- **project** (Project) - The project to resolve dependencies for.
- **scope** (PathScope) - The scope of the dependencies (e.g., COMPILE_RUNTIME).
### Example
```java
DependencyResolverRequest request = DependencyResolverRequest.build(session, DependencyResolverRequest.RequestType.COLLECT, project, PathScope.COMPILE_RUNTIME);
DependencyResolverResult result = session.getService(DependencyResolver.class).collect(request);
```
```
--------------------------------
### getBuild
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/project-and-build.md
Retrieves the effective build configuration for the project.
```APIDOC
## Build getBuild()
### Description
Returns the effective build configuration for this project.
### Returns
- **Build** - Build configuration, never null
```
--------------------------------
### Retrieve Effective Properties
Source: https://github.com/apache/maven/blob/master/_autodocs/configuration.md
Get a merged map of system and user properties where user properties take precedence.
```java
Map effective = session.getEffectiveProperties();
// Contains both system and user properties with correct precedence
```
--------------------------------
### Get project modules
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/project-and-build.md
Returns a list of module names for multi-module projects, returning an empty list for non-aggregator projects.
```java
@Nonnull
List getModules()
```
--------------------------------
### Run Maven Toolbox Tree Command
Source: https://github.com/apache/maven/blob/master/its/core-it-suite/src/test/resources/mng-8347-transitive-dependency-manager/README.md
Executes the toolbox tree plugin to visualize dependency resolution with a local repository tail.
```bash
mvn eu.maveniverse.maven.plugins:toolbox:tree -Dmaven.repo.local.tail=local-repo
```
--------------------------------
### Run Test Project
Source: https://github.com/apache/maven/blob/master/its/core-it-suite/src/test/resources/mng-8572-di-type-handler/README.md
Command to execute the validation phase of the test project.
```bash
cd test
mvn validate
```
--------------------------------
### Configure root directory
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/session.md
Sets the root directory for the session, which defaults to null if not provided.
```java
Builder withRootDirectory(@Nullable Path rootDirectory)
```
--------------------------------
### Run Maven Core Integration Tests
Source: https://github.com/apache/maven/blob/master/its/README.md
Use this command to run integration tests against a custom Maven build. Specify the local repository and the path to the Maven distribution zip.
```bash
mvn clean install -Prun-its -Dmaven.repo.local=`pwd`/repo -DmavenDistro=/path/to/apache-maven-dist.zip
```
--------------------------------
### Include additional properties files
Source: https://github.com/apache/maven/blob/master/src/site/markdown/configuring.md
Uses the ${includes} key to load additional properties files, supporting optional loading with a leading question mark.
```properties
${includes} = ?"${maven.user.conf}/maven-system.properties", \
?"${maven.project.conf}/maven-system.properties"
```
--------------------------------
### Collect dependencies from coordinates in Java
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/services.md
Demonstrates collecting transitive dependencies for a specific artifact coordinate without downloading files.
```java
@Nonnull
default DependencyResolverResult collect(
@Nonnull Session session,
@Nonnull DependencyCoordinates root,
@Nonnull PathScope scope)
```
```java
DependencyCoordinates root = session.createDependencyCoordinates(
"org.apache.maven", "maven-core", "jar", "", "4.0.0", "compile"
);
DependencyResolverResult result = session.getService(DependencyResolver.class)
.collect(session, root, PathScope.COMPILE_RUNTIME);
List deps = result.getRoot().getDependencies();
```
--------------------------------
### Run Maven Core Integration Tests with Proxy
Source: https://github.com/apache/maven/blob/master/its/README.md
This command is for running integration tests when behind a proxy. It includes parameters for proxy type, host, port, username, and password.
```bash
mvn clean install -Prun-its -Dmaven.repo.local=`pwd`/repo -DmavenDistro=/path/to/apache-maven-dist.zip -Dproxy.active=true -Dproxy.type=http -Dproxy.host=... -Dproxy.port=... -Dproxy.user=... -Dproxy.pass=...
```
--------------------------------
### Plugin Configuration Methods
Source: https://github.com/apache/maven/blob/master/_autodocs/types.md
Methods for accessing plugin metadata and defined goals.
```java
@Nonnull
String getGroupId()
```
```java
@Nonnull
String getArtifactId()
```
```java
@Nonnull
String getVersion()
```
```java
@Nonnull
Map getGoals()
```
--------------------------------
### Configure system properties for ProtoSession
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/session.md
Sets the system properties map for the session.
```java
Builder withSystemProperties(@Nonnull Map systemProperties)
```
--------------------------------
### Execute Maven Artifact version comparison tool
Source: https://github.com/apache/maven/blob/master/compat/maven-artifact/src/site/markdown/index.md
Run the executable JAR to parse and compare specific version strings using Maven's versioning logic.
```shell
$ java -jar maven-artifact-*.jar 3.2.4-alpha-1 3.2.4-SNAPSHOT 3.2.4.0
Display parameters as parsed by Maven (in canonical form) and comparison result:
1. 3.2.4-alpha-1 == 3.2.4.alpha.1
3.2.4-alpha-1 < 3.2.4-SNAPSHOT
2. 3.2.4-SNAPSHOT == 3.2.4.snapshot
3.2.4-SNAPSHOT < 3.2.4.0
3. 3.2.4.0 == 3.2.4
```
--------------------------------
### Run Maven Core ITs
Source: https://github.com/apache/maven/blob/master/its/src/site/markdown/index.md
Executes the integration tests using the default Maven version by activating the run-its profile.
```shell
mvn clean test -Prun-its
```
--------------------------------
### ProtoSession.Builder Methods
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/session.md
Methods available on the ProtoSession.Builder for configuring session parameters.
```APIDOC
## withUserProperties
### Description
Sets user-defined properties for the session.
### Signature
`Builder withUserProperties(@Nonnull Map userProperties)`
### Parameters
- **userProperties** (Map) - Required - User properties map
## withSystemProperties
### Description
Sets system properties for the session.
### Signature
`Builder withSystemProperties(@Nonnull Map systemProperties)`
### Parameters
- **systemProperties** (Map) - Required - System properties map
## withStartTime
### Description
Sets the session start time.
### Signature
`Builder withStartTime(@Nonnull Instant startTime)`
### Parameters
- **startTime** (Instant) - Required - Session start time
## withTopDirectory
### Description
Sets the top project directory.
### Signature
`Builder withTopDirectory(@Nonnull Path topDirectory)`
### Parameters
- **topDirectory** (Path) - Required - Top project directory
## withRootDirectory
### Description
Sets the root directory.
### Signature
`Builder withRootDirectory(@Nullable Path rootDirectory)`
### Parameters
- **rootDirectory** (Path) - Optional - Root directory
```
--------------------------------
### Configure Multiple Selectors
Source: https://github.com/apache/maven/blob/master/src/site/markdown/cache-configuration.md
Define multiple rules for different request types in a single configuration string.
```bash
mvn clean install -Dmaven.cache.config="
ArtifactResolutionRequest { scope: session, ref: soft }
ModelBuildRequest { scope: request, ref: soft }
ModelBuilderRequest VersionRangeRequest { ref: hard }
ModelBuildRequest * { ref: hard }
"
```
--------------------------------
### Run Maven Core ITs with Custom Distribution
Source: https://github.com/apache/maven/blob/master/its/src/site/markdown/index.md
Tests a specific Maven distribution by providing its path via the mavenHome system property.
```shell
mvn clean test -Prun-its -DmavenHome=
```
--------------------------------
### Default Maven Project Directory Layout
Source: https://github.com/apache/maven/blob/master/_autodocs/configuration.md
Visual representation of the standard directory structure for a Maven project.
```text
project-root/
├── pom.xml
├── src/
│ ├── main/
│ │ ├── java/ # Source code
│ │ ├── resources/ # Resource files
│ │ ├── filters/ # Resource filters
│ │ └── webapp/ # Web application (WAR projects)
│ └── test/
│ ├── java/ # Test source code
│ ├── resources/ # Test resources
│ └── filters/ # Test resource filters
├── target/ # Build output directory
│ ├── classes/ # Compiled classes
│ ├── test-classes/ # Compiled test classes
│ ├── ${artifact}-${version}.jar # Built JAR
│ └── ...
└── site/ # Generated site documentation
```
--------------------------------
### Collect Dependencies by PathScope
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/dependency-resolution.md
Demonstrates using PathScope constants to resolve dependencies for specific build phases like compilation, runtime, or testing.
```java
// Get all dependencies for compilation and runtime
DependencyResolverResult compRuntime = resolver.collect(
session, project, PathScope.COMPILE_RUNTIME
);
// Get test dependencies
DependencyResolverResult testDeps = resolver.collect(
session, project, PathScope.TEST_RUNTIME
);
// Get runtime-only dependencies (exclude compile-only)
DependencyResolverResult runtime = resolver.collect(
session, project, PathScope.RUNTIME
);
```
--------------------------------
### Access Local Repository Path
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/repositories-and-settings.md
Shows how to retrieve the file system path of the local repository and resolve specific artifact paths.
```java
LocalRepository localRepo = session.getLocalRepository();
Path repoPath = localRepo.getPath();
// ~/.m2/repository
// Accessing artifact files
Path artifact = repoPath.resolve("org/apache/maven/maven-core/4.0.0/maven-core-4.0.0.jar");
```
--------------------------------
### Build a project using ProjectBuilder
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/services.md
Defines the method signature for building a project from a request object.
```java
@Nonnull
ProjectBuilderResult build(ProjectBuilderRequest request)
throws ProjectBuilderException
```
--------------------------------
### SettingsBuilder.build(SettingsBuilderRequest request)
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/repositories-and-settings.md
Builds settings from a settings.xml file using the provided request object.
```APIDOC
## SettingsBuilder.build
### Description
Builds settings from a settings.xml file.
### Signature
`SettingsBuilderResult build(SettingsBuilderRequest request)`
### Parameters
- **request** (SettingsBuilderRequest) - Required - Build request
### Returns
- **SettingsBuilderResult** - Built settings
### Throws
- **SettingsBuilderException** - If settings.xml is invalid
### Example
```java
SettingsBuilderRequest request = SettingsBuilderRequest.build(
session,
Path.of(System.getProperty("user.home"), ".m2", "settings.xml")
);
SettingsBuilderResult result = session.getService(SettingsBuilder.class).build(request);
Settings settings = result.getSettings();
```
```
--------------------------------
### Retrieve Build Directories
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/project-and-build.md
Accessors for various build-related directory paths.
```java
String getDirectory()
```
```java
String getSourceDirectory()
```
```java
String getTestSourceDirectory()
```
--------------------------------
### Handle ArtifactDeployerException in Java
Source: https://github.com/apache/maven/blob/master/_autodocs/errors.md
Demonstrates catching an ArtifactDeployerException during the artifact deployment process.
```java
try {
ArtifactDeployerRequest request = ArtifactDeployerRequest.build(
session, artifacts, repository
);
session.getService(ArtifactDeployer.class).deploy(request);
} catch (ArtifactDeployerException e) {
System.err.println("Deployment failed: " + e.getMessage());
}
```
--------------------------------
### ProtoSession.getEffectiveProperties()
Source: https://github.com/apache/maven/blob/master/_autodocs/configuration.md
Retrieves the merged set of system and user properties.
```APIDOC
## Method: ProtoSession.getEffectiveProperties()
### Description
Returns a map containing both system and user properties, where user properties take precedence over system properties.
### Signature
Map getEffectiveProperties()
### Returns
- **Map** - A map containing the merged effective properties.
```
--------------------------------
### SettingsBuilder.build
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/services.md
Builds Maven Settings objects from a settings.xml file.
```APIDOC
## SettingsBuilder.build
### Description
Builds settings from a settings.xml file.
### Signature
`SettingsBuilderResult build(SettingsBuilderRequest request)`
### Parameters
- **request** (SettingsBuilderRequest) - Required - Build request
### Returns
- **SettingsBuilderResult** - Built settings
```
--------------------------------
### Mojo.execute()
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/plugin-development.md
The primary entry point for a Maven Mojo, invoked during the build lifecycle to perform the plugin's defined behavior.
```APIDOC
## void execute()
### Description
Executes the behavior defined by this Mojo. This is the primary entry point invoked during the Maven build lifecycle.
### Throws
- **Exception** - Any error should be thrown to signal failure
```
--------------------------------
### Configure Mojo Parameters with @Parameter
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/plugin-development.md
Defines configurable fields for a Mojo, supporting default values and CLI property overrides.
```java
@Parameter(
name = "name",
required = false,
readonly = false,
defaultValue = "value",
property = "property.name"
)
```
```java
@Parameter(
name = "outputDirectory",
defaultValue = "${project.build.outputDirectory}",
required = true
)
private File outputDirectory;
@Parameter(
name = "skip",
property = "maven.skip",
defaultValue = "false"
)
private boolean skip;
```
--------------------------------
### Run all benchmarks
Source: https://github.com/apache/maven/blob/master/impl/maven-xml/BENCHMARKS.md
Executes all JMH benchmarks located in the org.apache.maven.internal.xml package.
```bash
mvn test-compile exec:java -Dexec.mainClass="org.openjdk.jmh.Main" \
-Dexec.classpathScope=test \
-Dexec.args="org.apache.maven.internal.xml.*Benchmark" \
-pl impl/maven-xml
```
--------------------------------
### Constructing a Classpath String
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/dependency-resolution.md
Resolve dependencies for a project and use the ArtifactManager to build a system-specific classpath string.
```java
// Full runtime classpath
DependencyResolverResult result = resolver.resolve(
DependencyResolverRequest.build(
session,
DependencyResolverRequest.RequestType.RESOLVE,
project,
PathScope.COMPILE_RUNTIME
)
);
ArtifactManager artifactMgr = session.getService(ArtifactManager.class);
StringBuilder classpath = new StringBuilder();
for (Dependency dep : result.getRoot().getDependencies()) {
if (classpath.length() > 0) {
classpath.append(File.pathSeparator);
}
Path depPath = artifactMgr.getPath(dep);
classpath.append(depPath);
}
String classpathString = classpath.toString();
```
--------------------------------
### Resolve dependencies with PathScope
Source: https://github.com/apache/maven/blob/master/_autodocs/types.md
Demonstrates using PathScope to define the classpath during dependency collection.
```java
PathScope scope = PathScope.COMPILE_RUNTIME;
DependencyResolverResult result = session.getService(DependencyResolver.class)
.collect(session, project, scope);
```
--------------------------------
### Settings Interface Methods
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/repositories-and-settings.md
Methods to access configuration settings loaded from settings.xml.
```APIDOC
## Settings Interface Methods
### getLocalRepository()
Returns the configured local repository path, or null to use default.
### getProxies()
Returns configured proxy settings.
### getServers()
Returns configured server credentials.
### getMirrors()
Returns configured repository mirrors.
### getProfiles()
Returns configured profiles.
### getRepositories()
Returns configured repositories.
### getPluginRepositories()
Returns configured plugin repositories.
```
--------------------------------
### Build Maven Settings with SettingsBuilder
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/repositories-and-settings.md
Constructs a SettingsBuilderRequest and uses the session service to build and retrieve Maven settings.
```java
SettingsBuilderRequest request = SettingsBuilderRequest.build(
session,
Path.of(System.getProperty("user.home"), ".m2", "settings.xml")
);
SettingsBuilderResult result = session.getService(SettingsBuilder.class).build(request);
Settings settings = result.getSettings();
```
--------------------------------
### Retrieve Toolchains
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/session.md
Iterate through configured toolchain models available in the session.
```java
Collection toolchains = session.getToolchains();
for (ToolchainModel tc : toolchains) {
System.out.println(tc.getType());
}
```
--------------------------------
### Resolve dependencies with download
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/dependency-resolution.md
Collects and downloads all dependencies in the graph, making their paths available.
```java
@Nonnull
DependencyResolverResult resolve(DependencyResolverRequest request)
```
```java
DependencyResolverRequest request = DependencyResolverRequest.build(
session,
DependencyResolverRequest.RequestType.RESOLVE,
project,
PathScope.COMPILE_RUNTIME
);
DependencyResolverResult result = session.getService(DependencyResolver.class)
.resolve(request);
// Dependencies are downloaded and available
for (Dependency dep : result.getRoot().getDependencies()) {
Path depPath = session.getService(ArtifactManager.class).getPath(dep);
// Can read dep file
}
```
--------------------------------
### @Execute
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/plugin-development.md
Annotation to specify a phase or goal to execute before the current Mojo.
```APIDOC
## @Execute
### Description
Specifies a phase or goal to execute before this Mojo.
### Parameters
- **phase** (LifecyclePhase) - Optional - Lifecycle phase to execute
- **goal** (String) - Optional - Goal to execute
```
--------------------------------
### ProjectBuilder.build(ProjectBuilderRequest)
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/services.md
Builds a project from a POM file using a request object.
```APIDOC
## ProjectBuilder.build(ProjectBuilderRequest)
### Description
Builds a project from a POM file.
### Parameters
- **request** (ProjectBuilderRequest) - Required - Build request with source
### Returns
- **ProjectBuilderResult** - Built project
### Throws
- **ProjectBuilderException** - If POM is invalid
```
--------------------------------
### Configure Partial Merging
Source: https://github.com/apache/maven/blob/master/src/site/markdown/cache-configuration.md
Use partial configurations where specific selectors override or complement base settings.
```bash
# Base configuration for all ModelBuilderRequest
# More specific selectors can override individual properties
mvn clean install -Dmaven.cache.config="
ModelBuilderRequest { scope: session }
* ModelBuilderRequest { ref: hard }
ModelBuildRequest ModelBuilderRequest { ref: soft }
"
```
--------------------------------
### Version.compareTo(Version other)
Source: https://github.com/apache/maven/blob/master/_autodocs/api-reference/version-management.md
Compares this version with another version for ordering.
```APIDOC
## int compareTo(Version other)
### Description
Compares this version with another version for ordering.
### Parameters
- **other** (Version) - Required - Version to compare
### Returns
- **int** - Negative if this < other, positive if this > other, zero if equal
```
--------------------------------
### Visualize ClassRealm hierarchy
Source: https://github.com/apache/maven/blob/master/impl/maven-core/src/site/markdown/plugin-execution-isolation.md
A diagram representing the hierarchical relationship between the core Plexus realms and individual plugin realms.
```text
[plexus.core]
^
|
[plexus.core.maven]
^ ^
| |
[plugin0] [plugin1]
```