执行sbt tasks命令时看不到jacoco任务(-v也被尝试)

时间:2015-04-18 05:11:19

标签: scala sbt jacoco

我试图使用jacoco将测试报告集成到我的sbt项目中。 https://github.com/sbt/jacoco4sbt

我在jacoco.settings

中添加了build.sbt

我还在addSbtPlugin("de.johoop" % "jacoco4sbt" % "2.1.6")

中添加了plugins.sbt

当我运行sbt jacoco:check时,它运行正常。但是,当我尝试查看jacoco的任务数量时,sbt tasks并未显示与jacoco相关的任何内容。

我必须转到源代码来查看它。

https://github.com/sbt/jacoco4sbt/blob/master/src/main/scala/de/johoop/jacoco4sbt/Keys.scala

我是否知道为什么没有为sbt tasks命令显示jacoco,以及查看插件的所有可用任务的最佳方式

修改

我怀疑语句lazy val Config = config("jacoco") extend(Test) hide意味着jacoco扩展了Test任务,因此它不会在sbt任务中显示它,但我不确定。

1 个答案:

答案 0 :(得分:1)

运行

> tasks -v
  

修改:如果这不起作用,请考虑添加更多" v" s,例如tasks -vvv,甚至tasks -V以查看所有任务。

例如,我看到cover

This is a list of tasks defined for the current project.
It does not list the scopes the tasks are defined in; use the 'inspect' command for that.
Tasks produce values.  Use the 'show' command to run the task and print the resulting value.

  check                  Executes the tests and saves the execution data in 'jacoco.exec'.
  classesToCover         compiled classes (filtered by includes and excludes) that will be covered
  clean                  Cleaning JaCoCo's output-directory.
  compile                Compiles sources.
  console                Starts the Scala interpreter with the project classes on the classpath.
  consoleProject         Starts the Scala interpreter with the sbt and the build definition on the classpath and useful imports.
  consoleQuick           Starts the Scala interpreter with the project dependencies on the classpath.
  copyResources          Copies resources to the output directory.
  cover                  Executes the tests and creates a JaCoCo coverage report.
  coveredSources         Covered Sources.

还要注意它在开头说的内容(为清晰起见而包裹):

It does not list the scopes the tasks are defined in;
  use the 'inspect' command for that.

导致

> inspect cover
[info] No entry for key.
[info] Description:
[info]  Executes the tests and creates a JaCoCo coverage report.
[info] Delegates:
[info]  *:cover
[info]  {.}/*:cover
[info]  */*:cover
[info] Related:
[info]  jacoco:cover

所以你知道要运行jacoco:cover