Boutran
Boutran

Reputation: 10144

How can an SBT plugin depend on another plugin

I want to write a plugin "MyPlugin" that depends on the another plugin ("io.spray" %% "sbt-twirl" % "0.6.0").

Simply adding sbt-twirl in libraryDependencies will not work, because plugins get published with a different path scheme than standard libraries.

I also cannot declare sbt-twirl as a plugin dependency to MyPlugin project, because MyPlugin does not use the sbt-twirl directly, it is the project using MyPlugin that will indirectly use it.

MyPlugin provides a task that is meant to be run after sbt-twirl has generated it's sources (in sourceManaged) and after compilation.

A simple but non ideal solution would be to require the project using MyPlugin to also declare sbt-twirl as a plugin dependency, but it is not DRY because the two plugins will be sharing some settings (directories, versions, etc), and they will have to be repeated and compatible.

Upvotes: 22

Views: 2422

Answers (1)

Mark Harrah
Mark Harrah

Reputation: 7019

It should be the same definition as for using a plugin as a plugin, except that it goes in build.sbt or project/Build.scala instead of project/plugins.sbt:

addSbtPlugin("io.spray" % "sbt-twirl" % "0.6.0")

Upvotes: 32

Related Questions