Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sbt publish local: Undefined resolver 'local'

Tags:

scala

sbt

ivy

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?

like image 473
Martin Konicek Avatar asked Jan 15 '13 11:01

Martin Konicek


People also ask

What is sbt Resolver?

sbt resolver is the configuration for repository that contains jars and their dependencies. for example the below is a resolver definition for a repository called Sonatype and it points at snapshot releases (dev versions) resolvers += "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"

What does sbt publish do?

The publish action is used to publish your project to a remote repository. To use publishing, you need to specify the repository to publish to and the credentials to use. Once these are set up, you can run publish .

How do I clear my sbt cache?

You can use Pretty Clean to clean the all of dev tools caches including SBT. PrettyClean also cleans the SBT project's target folder.

What is the latest sbt version?

sbt 1.4. 0 / Zinc 1.4.


1 Answers

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

like image 162
Martin Konicek Avatar answered Nov 10 '22 16:11

Martin Konicek