sbt - How to write a plugin which depends on a task from another plugin? -


there great sbt plugin sbt-dependency-graph, provides dependencytree task show dependencies.

i want write sbt plugin depends on it, fails.

build.sbt

sbtplugin := true  name := "my-sbt-plugin-depends-on-another"  version := "0.1.2.1"  organization := "test20140913"  addsbtplugin("net.virtual-void" % "sbt-dependency-graph" % "0.7.5") 

src/main/scala/mysbtplugin.scala

import sbt._  object mysbtplugin extends autoplugin {    object autoimport {     lazy val hello = taskkey[unit]("hello task plugin")     lazy val hello2 = taskkey[unit]("hello task plugin2")   }    import autoimport._    override def trigger = allrequirements    override def requires = plugins.jvmplugin    val hellosetting = hello := println("hello plugin")    val hellosetting2 = hello2 := {     println("hello2, task result plugins:")     println(net.virtualvoid.sbt.graph.plugin.dependencytree.value)     println("=========================================")   }    override def projectsettings = seq(     hellosetting, hellosetting2   )  } 

then published local, , use in project:

build.sbt

name := "sbt--plugin-test"  version := "1.0"  scalaversion := "2.11.6"  net.virtualvoid.sbt.graph.plugin.graphsettings 

project/plugins.scala

loglevel := level.info  addsbtplugin("net.virtual-void" % "sbt-dependency-graph" % "0.7.5")  addsbtplugin("test20140913" % "my-sbt-plugin-depends-on-another" % "0.1.2.1") 

when run sbt on later project, reports:

reference undefined setting:    *:dependencytree *:hello2 (/users/twer/workspace/my-sbt-plugin-depends-on-another/src/main/scala/test20140913/mysbtplugin.scala:38)      did mean provided:dependencytree ?      @ sbt.init$class.uninitialized(settings.scala:262)     @ sbt.def$.uninitialized(def.scala:10)     @ sbt.init$class.delegate(settings.scala:188)     @ sbt.def$.delegate(def.scala:10) 

where wrong?

ps: plugin code here: https://github.com/freewind/my-sbt-plugin-depends-on-another

dependencytree defined specific configurations (well all of them), automatically delegates compile in shell.

try defining hello2 so:

  val hellosetting2 = hello2 := {     println("hello2, task result plugins:")     import net.virtualvoid.sbt.graph.plugin.dependencytree     println((dependencytree in compile).value)     println("=========================================")   } 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -