Blankman
Blankman

Reputation: 267040

sbt maven local resolver doesn't work when using Build.scala

I used to have my dependencies defined in my build.sbt file for my play! app, but now I have multiple projects I tried doing this in my build.scala file now:

resolvers += Resolver.mavenLocal

val webDependencies = Seq(
..
..
"com.example" % "blah" % "0.0.1-SNAPSHOT"
)

When I try and run or compile it says it it cannot resolve the dependency for some reason. I had the exact same thing in build.sbt and it worked, but now it doesnt' work when in build.scala.

The error shows this:

[info] Resolving com.example#blah;0.0.1-SNAPSHOT ...
[warn]  module not found: com.example#blah;0.0.1-SNAPSHOT
[warn] ==== local: tried
[warn]   /Users/blankman/.ivy2/local/com.example/blah/0.0.1-SNAPSHOT/ivys/ivy.xml
[warn] ==== public: tried
[warn]   http://repo1.maven.org/maven2/org/blah/blah/0.0.1-SNAPSHOT/blah-0.0.1-SNAPSHOT.pom
[warn] ==== Typesafe Releases Repository: tried
[warn]   http://repo.typesafe.com/typesafe/releases/org/blah/blah/0.0.1-SNAPSHOT/blah-0.0.1-SNAPSHOT.pom
[warn] ==== Typesafe Releases Repository: tried
[warn]   http://repo.typesafe.com/typesafe/releases/org/blah/blah/0.0.1-SNAPSHOT/blah-0.0.1-SNAPSHOT.pom
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: com.example#blah;0.0.1-SNAPSHOT: not found
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::

Why would it stop working and any ideas on how I can fix this issue?

Upvotes: 0

Views: 1660

Answers (1)

Eugene Zhulenev
Eugene Zhulenev

Reputation: 9734

This solution works for me:

val buildResolvers = resolvers ++= Seq(
    "Local Maven Repository"    at "file://"+Path.userHome.absolutePath+"/.m2/repository",
    "Typesafe Repo"             at "http://repo.typesafe.com/typesafe/releases/",
    "Sonatype Snapshots"        at "http://oss.sonatype.org/content/repositories/snapshots",
    "Sonatype Releases"         at "http://oss.sonatype.org/content/repositories/releases"
  )

def MyProject(name: String) = {
    Project(id = name, base = file(name)).
      settings(buildResolvers:_*)

Major difference I see, is that I explicitly add resolvers settings to project.

Upvotes: 2

Related Questions