Reputation: 967
I am working on two different projects, Both uses different maven .settings.xml
files.
When I switch between the projects, it re downloads all the maven dependencies in repository folder removing previous projects' dependencies.
Is there any way I can use two settings
and it maintains different repository for both projects.
Upvotes: 8
Views: 12320
Reputation: 3955
You can try to separate the two projects in different workspaces and you can configure each workspace with Eclipse. It is possible because Eclipse saves the configuration within each workspace. Therefore, for these workspaces, is possible specify different and specific repositories according with their Maven settings.xml
files.
For to do that, launch eclipse > go to preferences > choose maven > User Settings and click on "Update Settings"
UPDATE:
You should have a structure similar to the following:
Workspaces:
/Volumes/Stonehall/juanca/workspace-project-1
/Volumes/Stonehall/juanca/workspace-project-2
Projects:
/Volumes/Stonehall/juanca/workspace-project-1/project-1
/Volumes/Stonehall/juanca/workspace-project-2/project-2
Settings.xml:
/Volumes/Stonehall/juanca/.m2/settings-project-1.xml
/Volumes/Stonehall/juanca/.m2/settings-project-2.xml
Repositories:
/Volumes/Stonehall/juanca/.m2/repository-1
/Volumes/Stonehall/juanca/.m2/repository-2
Open and edit settings-project-1.xml
file. Searchs the localRepository
tag and replace the path, for example:
<localRepository>/Volumes/Stonehall/juanca/.m2/repository-1</localRepository>
Open and edit settings-project-2.xml
file. Searchs the localRepository
tag and replace with the other path, for example:
<localRepository>/Volumes/Stonehall/juanca/.m2/repository-2</localRepository>
Important: checks that the <localRepository>
tag is not commented for example:
<!-- localRepository
| The path to the local repository maven will use to store artifacts.
|
| Default: ${user.home}/.m2/repository
<localRepository>/path/to/local/repo</localRepository>
-->
<localRepository>/Volumes/Stonehall/juanca/.m2/repository</localRepository>
Eclipse:
Open the workspace-project-1
, go to preferences > choose maven > User Settings and click on "Update Settings" and replace with the new path:
/Volumes/Stonehall/juanca/.m2/settings-project-1.xml
The same way you should do for the workspace-project-2
, open the workspace-project-2
and go to preferences > choose maven > User Settings and click on "Update Settings" and replace with the other path:
/Volumes/Stonehall/juanca/.m2/settings-project-2.xml
With this configuration each project should download the dependencies in the differents repositories.
This configuration should work, but in case does not work, you should post your settings.xml file and the pom files of both projects, so that we can help you better
Upvotes: 9
Reputation: 266
You can create 2 separate workspaces in Eclipse. In each workspaces, you can provide respective settings.xml file
Upvotes: 0