ivysettings.xml: add local maven path
Asked Answered
A

4

25

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

Apologist answered 23/12, 2011 at 15:53 Comment(0)
O
33

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.

Octodecimo answered 23/12, 2011 at 18:47 Comment(2)
It's worth considering forcing .pom extension in ivy patterns, like it's suggested here. This way Ivy's POM conversion logic will kick in, which is relevant if you need to reference synthetic configurations like master.Koser
@Koser I did not know that, neat! Using the Maven local repo is a bad idea IMHO. It functions more like a cache. Makes much more sense to configure both ivy and Maven to pull from the same remote repos!Basrelief
T
3

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.

Thegn answered 23/12, 2011 at 16:16 Comment(0)
T
2

I found out that in the more recent versions of sbt you can do

sbt publish-m2
Teodorateodorico answered 23/5, 2014 at 20:55 Comment(4)
Awesome, how does the location of the Maven repository get modified with this command?Esemplastic
'sbt publish-m2' publishes to ~/.m2 directory. Is this what you are asking?Teodorateodorico
Thanks @Always, I was trying to understand why SBT wasn't paying attention to <localRepository> in the settings.xml.Esemplastic
It's sbt publishM2 for meBodega
E
0

Prior to 0.13.7, SBT ignored the Maven's settings.xml to use the <localRepository> setting. See https://github.com/sbt/sbt/issues/1589. In some cases, this will obviate the need to change ivysettings.xml when using publish-m2.

Esemplastic answered 23/10, 2014 at 13:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.