maven-artifact

raw JSON →
0.3.5 verified Fri May 01 auth: no python

A Python library for downloading and resolving Maven artifacts from Maven repositories (e.g., Maven Central). It provides a client for fetching POM files, artifacts, and their transitive dependencies, with caching support. Current version is 0.3.5, released periodically.

pip install maven-artifact
error ModuleNotFoundError: No module named 'maven_artifact'
cause The package is installed as maven-artifact but imported as maven_artifact (underscore instead of hyphen). This is correct; the error usually means the package is not installed.
fix
Run pip install maven-artifact to install the package.
error requests.exceptions.ConnectionError: HTTPSConnectionPool(host='repo1.maven.org', port=443): Max retries exceeded with url: /maven2/...
cause Network issue or Maven Central is unreachable. The library uses repo1.maven.org by default.
fix
Check your internet connection or try a different repository using MavenRepository class: from maven_artifact.repository import MavenRepository; repo = MavenRepository('https://jitpack.io')
error maven_artifact.exceptions.ArtifactNotFoundError: Artifact not found: com.example:my-lib:1.0.0
cause The specified artifact does not exist in the repository. Check the groupId, artifactId, and version.
fix
Verify the GAV coordinates. Ensure the version exists, and consider if the artifact is in a snapshot or different repository.
error ValueError: Not enough values to unpack (expected 3, got 2)
cause Attempting to use colon-separated string with GAV constructor incorrectly.
fix
Use GAV('group', 'artifact', 'version') instead of GAV('group:artifact:version')
gotcha The GAV class expects all three components (group, artifact, version). Do not include colon separators — pass them as separate arguments.
fix Use GAV('com.example', 'my-lib', '1.0.0') instead of GAV('com.example:my-lib:1.0.0')
gotcha Resolving dependencies can be slow for large projects with many transitive dependencies because it downloads and parses POM files. Consider using caching or limiting depth.
fix Set cache_dir parameter in MavenArtifact: artifact = MavenArtifact(gav, cache_dir='/tmp/maven-cache')
deprecated The method 'download_artifact' is deprecated in favor of 'download' since version 0.3.0.
fix Use artifact.download() instead of artifact.download_artifact()

Basic usage: instantiate a GAV, create MavenArtifact, download the JAR, and resolve dependencies.

from maven_artifact import MavenArtifact, GAV

# Define a Maven artifact coordinate (group:artifact:version)
gav = GAV('com.google.guava', 'guava', '31.0.1-jre')

# Create a MavenArtifact instance with default Maven Central
artifact = MavenArtifact(gav)

# Download the artifact JAR file (returns path to local file)
jar_path = artifact.download()
print(f'Downloaded JAR to: {jar_path}')

# Resolve transitive dependencies (returns list of GAV)
deps = artifact.resolve_dependencies()
for dep in deps:
    print(dep)