I have two sbt plugin projects that both use multi-project builds. I would like to use one of the plugins as a dependency for the other. I was able to get this working with single project builds, but once I move to the multi-project build, I can't seem to get the dependencies to link up correctly.
my-test-plugin
build.sbt
lazy val commonSettings = Seq(
organization := "com.example",
name := "my-test-plugin",
version := "0.1.0-SNAPSHOT",
scalaVersion := "2.10.5"
)
// The contents of root are largely unimportant here
lazy val root = (project in file(".")).settings(commonSettings: _*)
lazy val plugin = (project in file("plugin"))
.settings(commonSettings: _*)
.settings(
sbtPlugin := true
)
my-test-plugin/plugin/src/main/scala/PluginTest.scala
package com.example.test
// Sample code I would like to access from another plugin
object PluginTest {
def foo: Unit = println("test")
}
my-sub-plugin
build.sbt
lazy val commonSettings = Seq(
organization := "com.sample",
name := "my-sub-plugin",
version := "0.1.0-SNAPSHOT",
scalaVersion := "2.10.5"
)
lazy val root = (project in file(".")).settings(commonSettings: _*)
lazy val plugin = (project in file("plugin"))
.settings(commonSettings: _*)
.settings(
sbtPlugin := true,
libraryDependencies += Defaults.sbtPluginExtra("com.example" % "my-test-plugin" % "0.1.0-SNAPSHOT", "0.13", "2.10")
).dependsOn(root)
my-sub-plugin/plugin/src/main/scala/SubPluginTest.scala
package com.sample.test
object SubPluginTest {
def bar = com.example.test.PluginTest.foo
}
But the last file doesn't compile:
[error] /home/mike/code/sbt-tests/my-sub-plugin/plugin/src/main/scala/SubPluginTest.scala:4: object example is not a member of package com
[error] def bar = com.example.test.PluginTest.foo
[error] ^
When I publish-local
and plugin/publish-local
both projects (rather, just compile the second), the artifacts resolve correctly, but SubPlugintest.scala
fails to compile with the above error, as if the dependency isn't there. However, if I remove the root
projects and put the plugin files in root (without lazy vals or anything, just a flat build.sbt
structure), it works.
What am I missing here?
I don't think it's relevant, but I tried 0.13.5 and 0.13.8. I've also fruitlessly tried adding the dependency without sbtPluginExtra
, and putting them in plugins.sbt
as well (I didn't think that would work, but hey).
Edit:
The dependency jars appear exist locally and resolve correctly:
$ jar tf ~/.ivy2/local/com.example/my-test-plugin/scala_2.10/sbt_0.13/0.1.0-SNAPSHOT/jars/my-test-plugin.jar
META-INF/MANIFEST.MF
com/
com/example/
com/example/test/
com/example/test/PluginTest$.class
com/example/test/PluginTest.class
$ jar tf ~/.ivy2/local/com.example/my-test-plugin_2.10/0.1.0-SNAPSHOT/jars/my-test-plugin_2.10.jar
META-INF/MANIFEST.MF
com/
com/example/
com/example/test/
com/example/test/DummyCode.class
com/example/test/DummyCode$.class