sbt 插件 - publishLocal 路径问题

sbt plugin - publishLocal path issue

我有一个具有以下配置的 sbt 插件 build.sbt

name := "sbt-test-plugin"
organization := "os.test2"
version := "0.3"
sbtPlugin := true
scalaVersion := "2.12.6"
publishMavenStyle := false

lazy val root = (project in file("."))
  .settings(
    sbtPlugin := true
  )

build.properties

sbt.version = 1.1.2

运行 发布本地

[info] Done packaging.
[info] :: delivering :: os.test2#sbt-test-plugin;0.3 :: 0.3 :: release :: Wed Aug 21 12:16:21 EEST 2019
[info]  delivering ivy file to D:\Work\sbt-zip-master\target\scala-2.12\sbt-1.0\ivy-0.3.xml
[info]  published sbt-test-plugin to C:\Users\os\.ivy2\local\os.test2\sbt-test-plugin\scala_2.12\sbt_1.0[=12=].3\jars\sbt-test-plugin.jar
[info]  published sbt-test-plugin to C:\Users\os\.ivy2\local\os.test2\sbt-test-plugin\scala_2.12\sbt_1.0[=12=].3\srcs\sbt-test-plugin-sources.jar
[info]  published sbt-test-plugin to C:\Users\os\.ivy2\local\os.test2\sbt-test-plugin\scala_2.12\sbt_1.0[=12=].3\docs\sbt-test-plugin-javadoc.jar
[info]  published ivy to C:\Users\os\.ivy2\local\os.test2\sbt-test-plugin\scala_2.12\sbt_1.0[=12=].3\ivys\ivy.xml

之后我尝试在另一个项目中使用该插件并将以下行添加到 plugins.sbt

libraryDependencies += "os.test2" %% "sbt-test-plugin" % "0.3"

但是对它有未解决的依赖关系

[warn] ==== local: tried
[warn]   C:\Users\os\.ivy2\local\os.test2\sbt-test-plugin_2.12[=14=].3\ivys\ivy.xml

为什么发布库和试图找到库的两个路径不同?

C:\Users\os\.ivy2\local\os.test2\sbt-test-plugin\scala_2.12\sbt_1.0[=15=].3\ivys\ivy.xml
C:\Users\os\.ivy2\local\os.test2\sbt-test-plugin_2.12[=15=].3\ivys\ivy.xml

要添加对 sbt 插件的依赖,请使用 addSbtPlugin:

addSbtPlugin("os.test2" % "sbt-test-plugin" % "0.3")

通知单%addSbtPlugin 将添加正确的 Scala 和 sbt 版本后缀。