SBT AutoPlugin依赖性

时间:2018-10-29 16:51:47

标签: scala sbt

我已经创建了一个SBT插件,放置在项目文件夹中。该插件扩展了sbt.AutoPlugin并添加了自定义任务。

类似这样的东西:

object MyCustomTask extends AutoPlugin {
   ...
   lazy val myCustomTask = Def.task {
      runner.value.run("my.support.project.classpath.Utility")
   }
}

我有这个build.sbt

lazy val support = (project in file("support"))
  .settings(libraryDependencies ++= Seq(
    "com.h2database" % "h2" % "1.4.197"
  ))

lazy val root = (project in file("root"))
  .settings(...)
  .dependsOn(support) // <- how can I remove this?
  .enablePlugin(MyCustomTask)

我不想在root项目和support项目之间建立依赖关系,因为这样rootsupport继承了所有依赖关系,而它并没有{ t的需求(如h2database依赖项),但是如果我删除了dependsOn(support),则在MyCustomTask中定义的任务将找不到my.support.project.classpath.Utility

我可以将该依赖项移至MyCustomTask插件定义中吗?

1 个答案:

答案 0 :(得分:1)

可以将依赖项添加到插件中,以覆盖 Quantity | TotalPrice --------------- 2 | $22 ($11 + $11) 1 | $30 ($30) 3 | $63 ($11 + $22 + $30) 字段,如下所示:

projectSettings