sbt publish local: Undefined resolver 'local'
Asked Answered
M

1

13

When trying to publish-local in sbt, I get the following output:

[info] :: delivering :: com.mycompany#util_2.9.1;0.1.0-SNAPSHOT :: 0.1.0-SNAPSHOT :: integration :: Tue Jan 15 11:23:01 CET 2013
[info]  delivering ivy file to /Users/martink/code/my-project/util/target/scala-2.9.1/ivy-0.1.0-SNAPSHOT.xml
[trace] Stack trace suppressed: run last my-util/*:publish-local for the full output.
[error] (my-util/*:publish-local) Undefined resolver 'local'

I suspect this is because of some settings in my build file because publish-local works on fresh projects. Any ideas on how to make publish-local work again?

Montgolfier answered 15/1, 2013 at 11:5 Comment(0)
M
19

We found out the problem was caused by overriding external-resolvers:

val myRepo = "my-public" at "http://my-nexus-server/content/groups/public/" 
externalResolvers := Seq(publicRepo)

We did this to exclude the default Maven central repository from our resolvers. This, however, also removed the local resolver that is used by publish-local.

The solution was to add the local resolver back:

val ivyLocal = Resolver.file("local", file(Path.userHome.absolutePath + "/.ivy2/local"))(Resolver.ivyStylePatterns)
externalResolvers := Seq(ivyLocal, myRepo)

Another solution would be to not override externalResolvers but just disable Maven central.

resolvers := Seq(myRepo)
externalResolvers <<= resolvers map { rs =>
  Resolver.withDefaultResolvers(rs, mavenCentral = false)
}

Once you publish-local, Ivy seems to give preference to the local snapshot version over remote snapshot versions. To have your published artifact picked up by another project, just run sbt compile in that project (seems like sbt update is not even necessary).

See also http://www.scala-sbt.org/release/docs/Detailed-Topics/Library-Management.html

Montgolfier answered 15/1, 2013 at 11:5 Comment(1)
You might also be interested in overriding repositories at the user-level: scala-sbt.org/release/docs/Detailed-Topics/….Gravelblind

© 2022 - 2024 — McMap. All rights reserved.