sbt publish local:未定义的解析器'local'

时间:2013-01-15 11:05:47

标签: scala sbt ivy

在sbt中尝试publish-local时,我得到以下输出:

[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'

我怀疑这是因为我的构建文件中有一些设置,因为publish-local适用于新项目。关于如何让publish-local再次运作的任何想法?

1 个答案:

答案 0 :(得分:14)

我们发现问题是由覆盖external-resolvers

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

我们这样做是为了从我们的解析器中排除默认的Maven中央存储库。但是,这也删除了publish-local使用的本地解析程序。

解决方案是添加本地解析器:

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

另一种解决方案是不覆盖externalResolvers,而只是禁用Maven central。

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

一旦publish-local,Ivy似乎优先考虑远程快照版本的本地快照版本。要让您的已发布工件被另一个项目选中,只需在该项目中运行sbt compile(似乎甚至不需要sbt update)。

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