6

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?

Stig Brautaset
  • 2,602
  • 1
  • 22
  • 39

1 Answers1

2

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)
)
chemikadze
  • 815
  • 4
  • 12
  • This looks promising. Is there a way to do this from build.sbt? I don't like to use the Build.scala for more than absolutely necessary. – Stig Brautaset Jan 23 '14 at 13:02
  • Ok. Can you give a bit more full example of where the bit after the "..." goes then? I don't seem to be able to figure that out. – Stig Brautaset Jan 23 '14 at 13:06
  • [This answer](https://groups.google.com/forum/#!topic/simple-build-tool/-p-sXX0QXJI) says that "dependsOn is not intended for sequencing". So this might not be the right way to do this. – Rich Feb 25 '14 at 12:54
  • I am trying to use your answer, but I can't get it to work. What should I use for "yourProject", "...", "streams"? – Rich Feb 25 '14 at 18:31
  • I get "value test is not a member of Seq[Product with Serializable with sbt.TestOption]" – Rich Feb 27 '14 at 12:46
  • Well, I've made working example https://github.com/chemikadze/revolver-dependency-example – chemikadze Feb 27 '14 at 13:56