Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to manage different maven setting in eclipse for different projects?

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.

like image 929
abhinav3414 Avatar asked Mar 24 '17 09:03

abhinav3414


1 Answers

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, so you can specify the different repositories with their maven settings.xml files.

For to do that, launch eclipse > go to preferences > choose maven > User Settings and click on "Update Settings"

enter image description here

UPDATE:

You should have a structure similar to the following:

Workspaces:

/Volumes/Stonehall/juanca/workspace-project-1/
/Volumes/Stonehall/juanca/workspace-project-2/

Repositories:

/Volumes/Stonehall/juanca/.m2/settings-project-1.xml
/Volumes/Stonehall/juanca/.m2/settings-project-2.xml

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>/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

like image 114
JUAN CALVOPINA M Avatar answered Oct 15 '22 22:10

JUAN CALVOPINA M