Reputation: 43
I know that this is not the idea behind Maven but:
I would like to have a local maven repo (.m2) inside the progect directory with a relative path.
Is there any way I can have my pom do this? Is there a better alternative?
So, basically what I want is not to be dependent on any exterior repositorys.
Thx for your help :)
PS1 - I'm sort of a java noob (c/c++ here) and a total maven
PS2 - The settings.xml file on maven installation dir/conf has a localRepository element, but I believe I can't have a relative patch there. Additionally this would be not linked to the progect, but to the box where maven is installed.
Upvotes: 3
Views: 2886
Reputation: 486
I would like to have a local maven repo (.m2) inside the progect directory with a relative path. Is there any way I can have my pom do this?
Yes, there is a way: you can specify path to local repo by specifying in $M2_HOME\conf\setting.xml
But this approach is really not good if you (or other developers) work with more than one project.
Is there a better alternative?
Yes, there is a better alternative:) You can import any jar in you local maven repository so you will not depend on maven central repo and you will not be forced to store local repository inside your project. Check this tiny article How To Include Custom Library Into Maven Local Repository? to learn how to do it.
With this approach you can store all required 3rd party jars in your project as well as a shell/batch script that imports jars to the local repo. And developers will just execute the script to import dependencies to local repo instead of modifying maven settings to use local repo from some specific place (from the project).
Upvotes: 0
Reputation: 41126
Note that in pom.xml you can set the dependency reference to the location of specific jar file stored in file system, suppose you have a sub-folder lib under project root folder which contains all jar libraries:
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.0.4</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/commons-logging-1.0.4.jar</systemPath>
</dependency>
By doing this, the groupId, artifactId and version become meaningless. From my own experience, I saw a oracle project before which has many customized jar with others that not available via online maven repository, ugly but doable.
Upvotes: 4