I wrote a blog post about sequencing tasks that you might find useful.
If you want to combine tests and make sure everything is streamlined, one quick way to do this is to create a custom team. The following is an alias for the sts command:
lazy val commonSettings = Seq( scalaVersion := "2.11.4" ) lazy val specs2Core = "org.specs2" %% "specs2-core" % "2.4.15" val startTest = taskKey[Unit]("start test") val stopTest = taskKey[Unit]("stop test") lazy val root = (project in file(".")). aggregate(app, webapp). settings(commonSettings: _*). settings(addCommandAlias("sts", ";startTest;test;stopTest"): _*). settings( startTest in ThisBuild := { println("starting server...") Thread.sleep(500) }, stopTest in ThisBuild := { println("stopping server...") Thread.sleep(500) } ) lazy val app = (project in file("app")). settings(commonSettings: _*). settings( libraryDependencies += specs2Core % Test ) lazy val webapp = (project in file("webapp")). settings(commonSettings: _*). settings( libraryDependencies += specs2Core % Test )
You can replace the startTest in ThisBuild and stopTest in ThisBuild as you wish. Defining these parameters at the ThisBuild level, the sts command should work both at the root level and at the level of individual subprojects.
root> sts starting server... [success] Total time: 1 s, completed Jan 13, 2015 5:20:58 PM [info] HelloWorldSpec .... [info] Passed: Total 3, Failed 0, Errors 0, Passed 3 [success] Total time: 1 s, completed Jan 13, 2015 5:20:59 PM stopping server... [success] Total time: 1 s, completed Jan 13, 2015 5:20:59 PM root> project app [info] Set current project to app app> sts starting server... [success] Total time: 1 s, completed Jan 13, 2015 5:21:15 PM [info] HelloWorldSpec .... [info] Passed: Total 3, Failed 0, Errors 0, Passed 3 [success] Total time: 1 s, completed Jan 13, 2015 5:21:16 PM stopping server... [success] Total time: 1 s, completed Jan 13, 2015 5:21:16 PM
source share