sbt插件-publishLocal路径问题

时间:2019-08-21 09:38:01

标签: sbt sbt-plugin

我有一个具有以下配置的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

运行publishLocal

[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\0.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\0.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\0.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\0.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\0.3\ivys\ivy.xml

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

C:\Users\os\.ivy2\local\os.test2\sbt-test-plugin\scala_2.12\sbt_1.0\0.3\ivys\ivy.xml
C:\Users\os\.ivy2\local\os.test2\sbt-test-plugin_2.12\0.3\ivys\ivy.xml

1 个答案:

答案 0 :(得分:0)

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

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

注意单个%addSbtPlugin将添加适当的Scala和sbt版本后缀。

相关问题