Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can an SBT plugin depend on another plugin

Tags:

sbt

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.

like image 885
Max L. Avatar asked Jan 21 '13 15:01

Max L.


1 Answers

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")
like image 94
Mark Harrah Avatar answered Oct 18 '22 10:10

Mark Harrah