Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


Page properties


Status

Status
colourGreen
titleDONE
 

Version 3.9.0
Issue(s)

Jira
showSummaryfalse
serverASF JIRA
columnskey,summary,type,created,updated,due,assignee,reporter,priority,status,resolution
serverId5aa69414-a9e9-3523-82ec-879b028fb15b
keyMNG-3655

Jira
showSummaryfalse
serverASF JIRA
columnskey,summary,type,created,updated,due,assignee,reporter,priority,status,resolution
serverId5aa69414-a9e9-3523-82ec-879b028fb15b
keyMNG-4709

Sources
Developer(s) Tamas Cservenak 


Problem

By default, the Maven local repository is a single directory structure, stored typically in the user's home directory. This is used as a cache for multiple remote repositories and as a place to store locally installed artifacts.

This can be problematic when multiple remote repositories contain artifacts which use the same GAV (GroupId, ArtifactId, Version) but have different content.
For example repo A and repo B contain the same GAV (GroupId, ArtifactId, Version) with different content in the jar and pom:

repo A

No Format

repository
+- org
|  +- myproj
|  |  +- 1.0
|  |  |  +- myproj-1.0.pom
|  |  |  \- myproj-1.0.jar

repo B

No Format

repository
+- org
|  +- myproj
|  |  +- 1.0
|  |  |  +- myproj-1.0.pom
|  |  |  \- myproj-1.0.jar

If repo A is specified first in the build config, then the jar and pom from repo A will be downloaded to the local repository. If another build is then run which requires org:myproj:1.0 from repo B, Maven will use the incorrect jar and POM from repo A, since it is already available in the local repo. This is known as a GAV conflict because the two repositories have conflicting data and cannot be safely used together.

Related Discussion: httphttps://docscwiki.codehausapache.org/confluence/display/MAVEN/Local+repositoryRepository+separationImage RemovedSeparation

Proposed Solution

To solve this problem, Maven should use a separate local repository for each remote repository. Each local repository would function as a cache for the associated remote repository. The name of each local repository cache follows the format <repositoryId>-<url-hash>. In the event that the same repository ID is used to represent two different remote URLs, two separate repository caches would be created. If two repository IDs point to the same URL, the hash value can be used to identify that they are the same, and possibly store metadata that allows Maven to recognize the two as being the same.

No Format

.m2
+- repositories
|  +- central-<hash>
|  +- repoA-<hash>
|  \- repoB-<hash>

...

In addition, a separate repository should be used for installs/uploads to avoid conflicts with remote repositories.

No Format

.m2
+- repositories
|  +- central-<hash>
|  +- repoA-<hash>
|  \- repoB-<hash>
\- workspace

Related Jira issues httphttps://issues.apache.org/jira.codehaus/browse/MNG-3655https://issues.apache.org/jira/browse/MNG-3655Image Removed4709

Repositories vs. Plugin Repositories

This proposal is also related to separation of repositories for project dependencies is the use of plugin repositories as discussed in httphttps://jiraissues.codehausapache.org/jira/browse/MNG-4302Image Removed