Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ensure 're-start' task automatically runs before it:test

Tags:

scala

sbt

Is it possible to get the re-start (aka reStart) task to automatically run before I run the IntegrationTest target (it:test)?

I thought this would do it:

test <<= (test in IntegrationTest) dependsOn reStart

However, I'm getting this error:

build.sbt:54: error: not found: value reStart
test <<= (test in IntegrationTest) dependsOn reStart
                                             ^
[error] Type error in expression

By adding import Revolver._ I got a bit further, but it still fails. Now I get a more descriptive error, however:

build.sbt:55: error: type mismatch;
 found   : sbt.InputKey[spray.revolver.AppProcess]
 required: sbt.Scoped.AnyInitTask
    (which expands to)  sbt.Def.Initialize[sbt.Task[T]] forSome { type T }
test in IntegrationTest <<= (test in IntegrationTest) dependsOn reStart

Is there a way to get around that?

like image 252
Stig Brautaset Avatar asked Jan 23 '14 12:01

Stig Brautaset


1 Answers

You can define special TaskKey-typed task for that like this (working example):

lazy val reStart0 = TaskKey[AppProcess]("re-start-0")
lazy val emptyArgs = SettingKey[revolver.Actions.ExtraCmdLineOptions]("empty-args")

lazy val projectA = Project(
  id = "hello-a",
  base = file("./a"),
  settings = Project.defaultSettings ++ Revolver.settings
).settings(
  emptyArgs := revolver.Actions.ExtraCmdLineOptions(Nil, Nil),
  reStart0 <<= {
  (streams, Revolver.reLogTag, thisProjectRef, Revolver.reForkOptions, mainClass in Revolver.reStart, fullClasspath in Runtime, Revolver.reStartArgs, emptyArgs)
     .map(revolver.Actions.restartApp)
     .dependsOn(products in Compile)
  }
)

lazy val projectB = Project(
  id = "hello-b",
  base = file("./b"),
  settings = Project.defaultSettings ++ Revolver.settings ++ Defaults.itSettings)
.configs(IntegrationTest)
.settings(
  test in (IntegrationTest) <<= (test in IntegrationTest).dependsOn(reStart0 in projectA)
)
like image 176
chemikadze Avatar answered Nov 15 '22 04:11

chemikadze