Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding itSettings breaks the runner #12

Open
steinybot opened this issue Apr 8, 2021 · 2 comments
Open

Adding itSettings breaks the runner #12

steinybot opened this issue Apr 8, 2021 · 2 comments

Comments

@steinybot
Copy link

steinybot commented Apr 8, 2021

Reproduction: https://github.com/steinybot/bug-reports/tree/kamon/sbt-runner

This works fine:

scalaVersion := "2.13.5"

run / fork := true
sbt:bug-reports> inspect Compile/run/runner
[info] Task: sbt.ScalaRun
[info] Description:
[info] 	Implementation used to run a main class.
[info] Provided by:
[info] 	ProjectRef(uri("file:/Users/jason/source/bug-reports/"), "bug-reports") / Compile / run / runner
[info] Defined at:
[info] 	Defaults.scala:2566
[info] 	(kamon.instrumentation.sbt.SbtKanelaRunner.projectSettings) SbtKanelaRunner.scala:48

But adding integration test settings breaks it:

scalaVersion := "2.13.5"

run / fork := true
configs(IntegrationTest)
Defaults.itSettings
sbt:bug-reports> inspect Compile/run/runner
[info] Task: sbt.ScalaRun
[info] Description:
[info] 	Implementation used to run a main class.
[info] Provided by:
[info] 	ProjectRef(uri("file:/Users/jason/source/bug-reports/"), "bug-reports") / Compile / run / runner
[info] Defined at:
[info] 	/Users/jason/source/bug-reports/build.sbt:5

I haven't tracked down the cause of this yet but it is a bit strange. Defaults.itSettings are scoped to IntegrationTest so I don't see how that is messing with tasks in the Compile configuration.

One thing that I did notice is that SbtKanelaRunner overrides projectConfigurations. Should it be adding the configuration to super.projectConfigurations instead?

@steinybot
Copy link
Author

The problem is caused by sbt.Defaults#newRunnerSettings:

  private[this] lazy val newRunnerSettings: Seq[Setting[_]] = {
    val unscoped: Seq[Def.Setting[_]] =
      Seq(runner := ClassLoaders.runner.value, forkOptions := forkOptionsTask.value)
    inConfig(Compile)(unscoped) ++ inConfig(Test)(unscoped)
  }

These shouldn't have a configuration scope. sbt.Defaults#defaultConfigs already scopes them correctly.

@steinybot
Copy link
Author

The workaround is to manually add the runner back in after the itSettings:

Defaults.itSettings
Compile / run / runner := SbtKanelaRunner.kanelaRunnerTask.value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant