Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting Project specific maven repository

Tags:

eclipse

maven

I have multiple projects. I want to create different maven repository paths for each project. Means, each project should point to different folder as maven repository (by default C:/Users/USERNAME/.m2 is used as repo). I know that this may increase the download and same files if used in multiple projects will be downloaded/kept multiple times. But i want to separate out the repository for different projects so that i can bundle the repository along with my project's source code to be shared to the other person. I simply dont want to share my whole m2 repository (of size 2 gb) for a very small project sized 50 mb.

Regards,

Vibhav

like image 869
Vibhav Agrawal Avatar asked Jan 16 '12 22:01

Vibhav Agrawal


2 Answers

You can specify repository location via command line option -Dmaven.repo.local=

I'd have just put a wrapper script to start maven in the project location and specified repository in it (probably pointing to location inside the project for your use case).

like image 115
Alex Gitelman Avatar answered Sep 28 '22 06:09

Alex Gitelman


Thanks everyone for your comments.

I finally did the following:

  1. Setup each project as a separate workspace in eclipse
  2. Created a separate apache maven folder for each project (actually duplicating the maven home even though i am using same version of maven)
  3. From eclipse workspace, I pointed out the appropriate maven home
  4. configured the repository path (localRepository) in MAVEN_HOME/conf/settings.xml file from default ~./m2/repository to something like MAVEN_HOME/repo

This way, I could get separate maven repositories for each project (or I should say workspace).

Thanks, Vibhav Agrawal

like image 36
Vibhav Agrawal Avatar answered Sep 28 '22 05:09

Vibhav Agrawal