How can an SBT plugin depend on another plugin

喜你入骨 提交于 2019-12-20 17:31:48

问题


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.


回答1:


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")


来源:https://stackoverflow.com/questions/14441416/how-can-an-sbt-plugin-depend-on-another-plugin

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!