spray / sbt-revolver

An SBT plugin for dangerously fast development turnaround in Scala
Apache License 2.0
846 stars 55 forks source link

Can reStart support multiple dependency configurations? #116

Open romanchelsea opened 3 weeks ago

romanchelsea commented 3 weeks ago

Hi I'm relatively new to scala ecosystem.

I have reStart ("io.spray" % "sbt-revolver" % "0.10.0") configured in my project, and I would like to pass different javaOptions based on dependency configurations, e.g. Compile, Test, IntegrationTest, or even my custom configuration, like FuncTest (for functional tests).

If I'm reading the README correctly, reStart is just based on Compile, right?

I've been trying something like below, but my custom FuncTest configuration is not picking up a different logging configuration, i.e. logback.funcTest.xml, verified by checking the java process in shell.

// sbt.version = 1.7.1
// scala version = 2.13.8

lazy val FuncTest = config("run functional tests").extend(

lazy val hello = (project in file("."))
  .settings(
      // ... 
      reStart / mainClass := Some("com.example.MyApplication"),
      reStart / javaOptions ++= Seq(
        "-Dlogback.configurationFile=logback.development.xml",
      ),
      FuncTest / reStart / javaOptions ++= Seq(
        "-Dlogback.configurationFile=logback.funcTest.xml",
      )
   )

However, running below command in sbt shell works,

// in sbt shell
hello/reStart --- "-Dlogback.configurationFile=logback.funcTest.xml"

Would you please shed some light? Thanks!

jrudolph commented 3 weeks ago

You are right. Other scopes than Compile are not supported out of the box. In fact, it's not even just Compile because it also has to take Runtime resources into account as well. I think that was the main blocker why I never tried to get anything else working (e.g. Test would be useful often as well). One would have to research how Compile and Runtime resources are used together for these kinds of things and then see how that would transfer to Test and even custom ones. I think your best bet could be to copy the whole RevolverPlugin.settings block into your build and try to adapt it to work with your custom scope.

jrudolph commented 3 weeks ago

Btw. one question would be whether you really need run your tests or integrations test with sbt-revolver? Couldn't you just run them with test or run in which case just the normal config (without reStart bits) should work out-of-the-box?