user5168843
user5168843

Reputation:

Maven Multiple Local Repository

I have multiple Maven project in my Local, by default maven repository in my local is at ~/.m2/repository.

Now I wanted to create different maven repository for each Maven project.

i.e.

  1. Maven Project 1 = ~/.m2/repository
  2. Maven Project 2 = ~/.m3/repository
  3. Maven Project 3 = ~/.m3/repository

Edit: I am using Servicemix as a container.

Upvotes: 2

Views: 1679

Answers (3)

charlie_pl
charlie_pl

Reputation: 3094

There seems to be new configuration option, not very well documented, hinted at in https://maven.apache.org/resolver/local-repository.html that allows for repository splitting.

$ mvn ... -Daether.enhancedLocalRepository.split \
          -Daether.enhancedLocalRepository.localPrefix=maven-resolver/mresolver-253
          -Daether.enhancedLocalRepository.splitRemoteRepository

The localPrefix is what I think you are looking for.

You will need least Maven 3.9.0

Upvotes: 0

user5164185
user5164185

Reputation:

You need to modify your Maven settings.xml which is under maven/conf folder, there you will find tag localRepository, you need to modify it accordingly, default value is ${user.home}/.m2/repository

but Maven create repository one at a time that means for each project you need to change your settings.xml

Upvotes: 0

Claus Ibsen
Claus Ibsen

Reputation: 55550

You can configure the path to the local repository in your maven settings.xml configuration file: https://maven.apache.org/guides/mini/guide-configuring-maven.html

Upvotes: 1

Related Questions