Take the 2-minute tour ×

For my multi-project build, I'm trying to create a verify task that just results in scct:test and then scalastyle being executed in order. I would like scct:test to execute for all the subprojects, but not the top-level project. (If it executes for the top-level project, I get "timed out waiting for coverage report" from scct, since there's no source and no tests in that project.) What I had thought to do was to create verify as a task with dependencies on scct:test and scalastyle. This has turned out to be fairly baroque. Here is my Build.scala from my top-level project/ directory:

object MyBuild extends Build {
  val verifyTask = TaskKey[Unit]("verify", "Compiles, runs tests via scct:test and then runs scalastyle")
  val scctTestTask = (test in ScctPlugin.Scct).scopedKey
  val scalastyleTask = PluginKeys.scalastyleTarget.scopedKey

  lazy val root = Project("rootProject",
                      settings =  Defaults.defaultSettings ++
                                  ScalastylePlugin.Settings ++
                                  ScctPlugin.instrumentSettings ++
                                  ScctPlugin.mergeReportSettings ++
                                    verifyTask in Global := {},
                                    verifyTask <<= verifyTask.dependsOn(scctTestTask, scalastyleTask)
              ) aggregate(lift_webapp, selenium_tests)

  lazy val subproject_1 = Project(id = "subproject_1", base = file("subproject_1"))

  lazy val subproject_2 = Project(id = "subproject_2", base = file("subproject_2"))

However, the verify task only seems to exist for the root project; when I run it I don't see the same task being run in the subprojects. This is exactly the opposite of what I want; I'd like to issue sbt verify and have scct:test and scalastyle run in each of the subprojects but not in the top-level project. How might I go about doing that?

share|improve this question

1 Answer 1

I may be wrong, but you are defining the verify task dependency only for the current project.

Maybe you can try:

   verifyTask in Global := {},
   verifyTask <<= (verifyTask in Global).dependsOn(scctTestTask, scalastyleTask)

Or you can add the verifyTask settings to all your modules.

share|improve this answer
It's true that I'm defining the task dependency for the current project, but I was under the impression that aggregate propagated the tasks down to the aggregated projects. But thanks for the tip, which I'll try out. With regard to adding verifyTask to all the modules, true enough, but that was what I was trying to avoid with this exercise. –  Paul Blair Aug 25 '13 at 14:37
Unfortunately, the suggestion didn't seem to work any better than what I did originally. –  Paul Blair Aug 30 '13 at 13:29

Your Answer


