Search code examples
sbtsbt-plugin

sbt plugin - publishLocal path issue


I have an sbt plugin with the following configuration 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

run 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

after that I have tried to use that plugin in another project and added the following line to the plugins.sbt

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

But got unresolved dependencies on it

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

Why that two paths where library is published and library is tried to be found are different?

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

Solution

  • To add a dependency on an sbt plugin, use addSbtPlugin:

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

    Notice single %. addSbtPlugin will add the proper Scala and sbt version suffixes.