Source: openaf-opacks 87b07e97. See documentation baseline for availability and verification.

Build and test commands use the package’s source directory; installation and library examples use the installed oPack.

Maven oPack

Provides a comprehensive programmatic interface to search, download, parse, and resolve Maven dependencies (with full transitive resolution) using the Eclipse Aether and Apache Maven Model APIs inside OpenAF.

Usage

Loading the oPack

require("maven.js");

1. Advanced Maven Resolver & POM Parser Capabilities

These features allow programmatic dependency resolution, transitive dependency calculations, repository lookups, and POM file parsing.

Resolving Dependencies Transitively

// Initialize resolver (defaults to local ~/.m2/repository and Maven Central)
var m = new Maven();

// Resolve a coordinate (returns array of resolved artifacts with local absolute paths)
var resolved = m.resolve("org.apache.commons:commons-email:1.5");
print(resolved);
/*
[
  {
    "groupId": "org.apache.commons",
    "artifactId": "commons-email",
    "version": "1.5",
    "classifier": "",
    "extension": "jar",
    "file": "/Users/user/.m2/repository/org/apache/commons/commons-email/1.5/commons-email-1.5.jar"
  },
  {
    "groupId": "com.sun.mail",
    "artifactId": "javax.mail",
    "version": "1.5.6",
    ...
  }
]
*/

Parsing a pom.xml File

var m = new Maven();
var pom = m.parsePom("pom.xml");

print(pom.groupId);
print(pom.artifactId);
print(pom.version);
print(pom.dependencies);

Resolving Dependencies Directly from pom.xml

var m = new Maven();
var dependencies = m.resolveDependenciesFromPom("pom.xml");
print(dependencies);

Custom Resolver Configuration

You can customize the local repository path and remote repositories when instantiating Maven:

var m = new Maven(
  "/tmp/my_local_repo",
  [
    { id: "central", type: "default", url: "https://repo1.maven.org/maven2/" },
    { id: "custom-repo", type: "default", url: "https://my.company.repo/maven2/" }
  ]
);

2. Legacy Maven Repo Access Wrapper Capabilities

These features are maintained for fast searching and artifact fetching directly from Maven repositories.

Searching Maven Repository

var m = new Maven();
var results = m.search("gson");
print(results);

Fetching a Specific File/Jar

var m = new Maven();
// Downloads the latest version of gson jar matching the template
m.getFile("com.google.code.gson.gson", "gson-{{version}}.jar", "/path/to/output");

Removing Old Versions

var m = new Maven();
m.removeOldVersions("com.google.code.gson.gson", "gson-{{version}}.jar", "/path/to/output");

Backward Compatibility

MavenResolver is fully preserved as an alias to Maven. Existing code instantiating new MavenResolver() will run exactly as before:

var mr = new MavenResolver();
var resolved = mr.resolve("org.apache.commons:commons-email:1.5");

Dependency refresh (2026-10-09)

The 20261009 dependency refresh targets Maven Resolver 2.0.24 and Maven 4.0.0-rc-7. Repository maintenance holds preserve the Maven 4 API line and the existing HTTP transporter 2.0.0-alpha-2; selecting latest stable for those artifacts would instead choose incompatible older API lines. The resolver validator is initialized with the map required by Resolver 2.x.

The maintenance job runs a checkout-local dependency-resolution and alias smoke test before applying this bundle.


This site uses Just the Docs, a documentation theme for Jekyll.