添加到项目中的libraryDependencies时插件的解析失败?

时间:2014-01-14 09:55:48

标签: scala sbt ivy

当我运行sbt publishLocal时,插件将在<ivy-repository>/<org>/<plugin>/<scala-version>/<sbt-version>/<plugin-version>/...

中生成

例如:

[info]  published sbt-cloudengine to /Users/hanxue/.ivy2/local/net.entrypass/sbt-cloudengine/scala_2.10/sbt_0.13/0.2.1/jars/sbt-cloudengine.jar

如何从输出路径中排除<scala-version><sbt-version>

当我在build.sbt

中添加插件作为依赖项时,此路径导致解析失败
[warn] ==== Local Ivy Repository: tried
[warn]   file:///Users/hanxue/.ivy2/local/net/entrypass/sbt-cloudengine/0.2.1/sbt-cloudengine-0.2.1.pom

插件的build.sbt是:

sbtPlugin := true

name := "sbt-cloudengine"

organization := "net.entrypass"

version := "0.2.1"

description := "sbt plugin for managing Google Cloud Engine resources"

licenses := Seq("BSD License" -> url("https://github.com/hanxue/sbt-cloudengine/blob/master/LICENSE"))

scalacOptions := Seq("-deprecation", "-unchecked")

publishArtifact in (Compile, packageBin) := true

publishArtifact in (Test, packageBin) := false

publishArtifact in (Compile, packageDoc) := false

publishArtifact in (Compile, packageSrc) := false

publishMavenStyle := false

更新1

这就是项目<rootdir>/build.sbt

中引用插件的方式
resolvers += "Local Ivy Repository" at "file://"+Path.userHome.absolutePath+"/.ivy2/local"

libraryDependencies ++= Seq(
    "net.entrypass" % "sbt-cloudengine" % "0.2.1"
)

这是目录列表

$ ls -R ~/.ivy2/local/net.entrypass/sbt-cloudengine/scala_2.10/sbt_0.13/0.2.1/
ivys    jars    poms

/Users/hanxue/.ivy2/local/net.entrypass/sbt-cloudengine/scala_2.10/sbt_0.13/0.2.1//ivys:
ivy.xml     ivy.xml.md5 ivy.xml.sha1

/Users/hanxue/.ivy2/local/net.entrypass/sbt-cloudengine/scala_2.10/sbt_0.13/0.2.1//jars:
sbt-cloudengine.jar     sbt-cloudengine.jar.sha1
sbt-cloudengine.jar.md5

/Users/hanxue/.ivy2/local/net.entrypass/sbt-cloudengine/scala_2.10/sbt_0.13/0.2.1//poms:
sbt-cloudengine.pom     sbt-cloudengine.pom.sha1
sbt-cloudengine.pom.md5

1 个答案:

答案 0 :(得分:2)

由于您要发布sbt插件而不是库,因此该路径将正确包含sbt版本和scala版本。 您的问题来自于您尝试使用libraryDependencies加载插件的事实。相反,您必须使用文件project/plugins.sbt,其中包含以下内容:

addSbtPlugin("net.entrypass" % "sbt-cloudengine" % "0.2.1")

这样,sbt将在当前scala和sbt版本的帮助下使用正确的路径搜索插件。