Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ivysettings.xml: add local maven path

Tags:

java

maven

ivy

How to add a local path (not URL) to ivysettings.xml? I need to add my Maven local repository (/Users/me/.m2/repository to it.

Thanks

like image 913
pistacchio Avatar asked Dec 23 '11 15:12

pistacchio


People also ask

How do I access my local Maven repository?

1) Maven Local Repository By default, maven local repository is %USER_HOME%/. m2 directory. For example: C:\Users\SSS IT\. m2.

Where is .m2 maven folder?

xml file. Locate the Maven install directory for your operating system. It is usually installed in USER_HOME/. m2/ directory.


2 Answers

Try the following ivysettings.xml file:

<ivysettings>     <settings defaultResolver="default"/>     <property name="m2-pattern" value="${user.home}/.m2/repository/[organisation]/[module]/[revision]/[module]-[revision](-[classifier]).[ext]" override="false" />     <resolvers>         <chain name="default">             <filesystem name="local-maven2" m2compatible="true" >                 <artifact pattern="${m2-pattern}"/>                 <ivy pattern="${m2-pattern}"/>             </filesystem>             <ibiblio name="central" m2compatible="true"/>         </chain>     </resolvers> </ivysettings> 

It includes Maven central in case the dependency is missing from the local Maven repo.

Note:

The benefits of re-using a local Maven repository are limited. Ivy caches jars retrieved from repostories.

like image 143
Mark O'Connor Avatar answered Oct 13 '22 00:10

Mark O'Connor


Ivy dependencies are resolved with "Resolvers".

This page is pretty good for understanding the basics of how they work.

http://ant.apache.org/ivy/history/latest-milestone/settings/resolvers.html

Specifically : How can I "resolve" a local maven repository ?

Ivy has a "FileSystemResolver" which, rather than taking in a web address, can simply resolve from a local, root path. Note that there are some gotchas when things get complicated, like this one : http://ant.apache.org/ivy/history/latest-milestone/settings/resolvers.html . Resolvers are similar to maven Repository tags, in that they define a resource.

A quick word of advice

Remember that once you customize ivysettings.xml if you are using an IDE, you will have to tell it to specifically use YOUR ivysettings.xml file, rather than some internal default.

like image 29
jayunit100 Avatar answered Oct 12 '22 23:10

jayunit100