apache / apache/maven

Feature Request: CLI Option to Force Download of Both POM and JAR Files for All Dependencies

Open
#11,242 10 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Java
Stars
5.3k
Forks
3.1k
Avg merge
20h 42m
Merged PRs (30d)
297

Description

### New feature, improvement proposal

Currently, Maven downloads POM files for all dependencies, but only downloads JAR files when they are required for the build. This behavior causes issues when local Maven repositories are used by other build tools, such as sbt (via Ivy or Coursier), which often fail when a POM exists locally, but the corresponding JAR does not.

**Proposed Feature:**
Add a new CLI option, for example:

```
mvn dependency:resolve -DforceDownloadAllArtifacts=true
```

or

```
mvn -DdownloadAllArtifacts
```

When enabled, Maven should download both the POM and JAR files for every direct and transitive dependency defined in the project.

**Use Case:**
This feature would make local Maven repositories fully compatible with sbt and similar tools that expect both POM and JAR artifacts to exist locally. It would also help in offline builds and multi-tool environments where artifact completeness is critical.

**Expected Behavior:**
When the new flag is set, Maven should:

* Resolve all dependencies (direct and transitive).
* Download both POM and JAR files for each dependency.
* Store them in the local repository, regardless of whether the build currently needs the JAR.

**Motivation:**
This feature would prevent inconsistent local repository states that currently lead to missing JAR resolution failures in sbt’s Ivy or Coursier-based dependency resolution. It would also provide a more predictable and complete local cache for cross-build-tool interoperability.

As noted in the Coursier's [documentation](https://get-coursier.io/docs/other-repositories):

```
Avoid using ~/.m2/repository as a repository if you can. This is maven's internal file-system cache and it's not meant to be read by external tools. By using it you are risking running into some issues like e.g. directories with POMs inside but without corresponding jar files. You can read more about it here and here.
```

This highlights a real and recurring issue caused by Maven’s current behavior. Adding an option to force JAR downloads would eliminate such inconsistencies and improve interoperability across tools.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.