Search code examples
mavensbtresolver

Local File Resolution against local Maven repository


I have put a local repo resolver line into the build.sbt:

resolvers += "Local Repo" at "file://" + Path.userHome.absolutePath + "/.m2/repository"

Also I installed a file locally using mvn install

mvn org.apache.maven.plugins:maven-install-plugin:2.5.1:install-file  -Dfile=c:\shared\py4j-0.8.1.jar -DgroupId=net.sf.py4j  -DartifactId=py4j -Dversion=0.7 -Dpackaging=jar

Here we can see the file was installed into the local repo:

C:\Users\S80035683\.m2\repository\net\sf>dir C:\Users\S80035683\.m2\repository\net\sf\py4j\py4j\0.7\py4j-0.7.pom

 Directory of C:\Users\S80035683\.m2\repository\net\sf\py4j\py4j\0.7

05/13/2014  12:52 PM               457 py4j-0.7.pom

But during the build process the file can not be found:

[warn]  module not found: net.sf.py4j#py4j;0.7
[warn] ==== local: tried
[warn]   C:\Users\S80035683\.ivy2\local\net.sf.py4j\py4j\0.7\ivys\ivy.xml
[warn] ==== public: tried
[warn]   http://repo1.maven.org/maven2/net/sf/py4j/py4j/0.7/py4j-0.7.pom
[warn] ==== Apache repo: tried
[warn]   https://repository.apache.org/content/repositories/releases/net/sf/py4j/py4j/0.7/py4j-0.7.pom
[warn] ==== Cloudera repo: tried
[warn]   https://repository.cloudera.com/artifactory/repo/org/apache/kafka/kafka/0.7.2-spark/net/sf/py4j/py4j/0.7/py4j-0.7.pom
[warn] ==== Local Repo: tried
[warn]   file://C:/Users/S80035683/.m2/repository/net/sf/py4j/py4j/0.7/py4j-0.7.pom

Note in particular the last line:

file://C:/Users/S80035683/.m2/repository/net/sf/py4j/py4j/0.7/py4j-0.7.pom

That is the same path that we installed to earlier - i.e the file does exist

C:\Users\S80035683\.m2\repository\net\sf>dir C:\Users\S80035683\.m2\repository\net\sf\py4j\py4j\0.7\py4j-0.7.pom

 Directory of C:\Users\S80035683\.m2\repository\net\sf\py4j\py4j\0.7

05/13/2014  12:52 PM               457 py4j-0.7.pom

Solution

  • The issue is Windows-specific. There is another question that has helpful pointers on how to resolve.

    SBT doesn't find file in local maven repository although it's there

    Specifically one of the following three means to resolve may be used:

    file:// needs to be file:///
    

    (that is specific to windows..)

    OR: better /portable solutions:

    resolvers += Resolver.mavenLocal
    

    OR

    resolvers += "Local Maven Repository" at "file:///"+Path.userHome+"/.m2/repository"