{"id":23128,"library":"maven-artifact","title":"maven-artifact","description":"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.","status":"active","version":"0.3.5","language":"python","source_language":"en","source_url":"https://github.com/nicollaspetit/maven-artifact","tags":["maven","artifact","resolver","dependencies","java","build-tools"],"install":[{"cmd":"pip install maven-artifact","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"HTTP client for downloading artifacts and metadata from Maven repositories","package":"requests","optional":false},{"reason":"XML parsing for POM files","package":"lxml","optional":false}],"imports":[{"note":"Correct top-level import; wrong path is based on outdated versions or doc examples","wrong":"from maven_artifact.artifact import MavenArtifact","symbol":"MavenArtifact","correct":"from maven_artifact import MavenArtifact"},{"note":"","wrong":"","symbol":"GAV","correct":"from maven_artifact import GAV"},{"note":"","wrong":"","symbol":"MavenRepository","correct":"from maven_artifact.repository import MavenRepository"}],"quickstart":{"code":"from maven_artifact import MavenArtifact, GAV\n\n# Define a Maven artifact coordinate (group:artifact:version)\ngav = GAV('com.google.guava', 'guava', '31.0.1-jre')\n\n# Create a MavenArtifact instance with default Maven Central\nartifact = MavenArtifact(gav)\n\n# Download the artifact JAR file (returns path to local file)\njar_path = artifact.download()\nprint(f'Downloaded JAR to: {jar_path}')\n\n# Resolve transitive dependencies (returns list of GAV)\ndeps = artifact.resolve_dependencies()\nfor dep in deps:\n    print(dep)","lang":"python","description":"Basic usage: instantiate a GAV, create MavenArtifact, download the JAR, and resolve dependencies."},"warnings":[{"fix":"Use GAV('com.example', 'my-lib', '1.0.0') instead of GAV('com.example:my-lib:1.0.0')","message":"The GAV class expects all three components (group, artifact, version). Do not include colon separators — pass them as separate arguments.","severity":"gotcha","affected_versions":"all"},{"fix":"Set cache_dir parameter in MavenArtifact: artifact = MavenArtifact(gav, cache_dir='/tmp/maven-cache')","message":"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.","severity":"gotcha","affected_versions":"all"},{"fix":"Use artifact.download() instead of artifact.download_artifact()","message":"The method 'download_artifact' is deprecated in favor of 'download' since version 0.3.0.","severity":"deprecated","affected_versions":">=0.3.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run pip install maven-artifact to install the package.","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.","error":"ModuleNotFoundError: No module named 'maven_artifact'"},{"fix":"Check your internet connection or try a different repository using MavenRepository class: from maven_artifact.repository import MavenRepository; repo = MavenRepository('https://jitpack.io')","cause":"Network issue or Maven Central is unreachable. The library uses repo1.maven.org by default.","error":"requests.exceptions.ConnectionError: HTTPSConnectionPool(host='repo1.maven.org', port=443): Max retries exceeded with url: /maven2/..."},{"fix":"Verify the GAV coordinates. Ensure the version exists, and consider if the artifact is in a snapshot or different repository.","cause":"The specified artifact does not exist in the repository. Check the groupId, artifactId, and version.","error":"maven_artifact.exceptions.ArtifactNotFoundError: Artifact not found: com.example:my-lib:1.0.0"},{"fix":"Use GAV('group', 'artifact', 'version') instead of GAV('group:artifact:version')","cause":"Attempting to use colon-separated string with GAV constructor incorrectly.","error":"ValueError: Not enough values to unpack (expected 3, got 2)"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}