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 overrides settings in other configuration scopes #6436

Closed
steinybot opened this issue Apr 8, 2021 · 2 comments · Fixed by #6457
Closed

Adding itSettings overrides settings in other configuration scopes #6436

steinybot opened this issue Apr 8, 2021 · 2 comments · Fixed by #6457
Labels

Comments

@steinybot
Copy link
Contributor

steps

sbt version: 1.5.0

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

import scala.util.{Success, Try}

TaskKey[Unit]("runIt") := {
  (Compile / run / runner).value.run("foo", Seq.empty, Seq.empty, state.value.log)
}

Compile / run / runner := new Run(_ => getClass.getClassLoader, false) {

  override def run(mainClass: String, classpath: Seq[File], options: Seq[String], log: Logger): Try[Unit] = {
    println("Gotcha!")
    Success(())
  }
}

configs(IntegrationTest)
Defaults.itSettings

problem

sbt:bug-reports> runIt
[info] compiling 1 Scala source to /Users/jason/source/bug-reports/target/scala-2.12/classes ...
[info] Non-compiled module 'compiler-bridge_2.12' for Scala 2.12.13. Compiling...
[info]   Compilation completed in 11.305s.
[info] running foo
[error] (run-main-0) java.lang.ClassNotFoundException: foo
[success] Total time: 12 s, completed 8/04/2021, 1:42:18 PM

The Compile / run / runner is being overridden by seemingly unrelated settings (itSettings are scoped to the IntegrationTest configuration).

sbt.Defaults#newRunnerSettings have the Compile and Test configuration scopes but they should be unscoped.

expectation

sbt:bug-reports> runIt
Gotcha!
[success] Total time: 0 s, completed 8/04/2021, 1:41:54 PM

notes

Initially reported as kamon-io/sbt-kanela-runner#12

@steinybot steinybot added the Bug label Apr 8, 2021
@eed3si9n
Copy link
Member

eed3si9n commented Apr 8, 2021

@steinybot Thanks for the report. It seems like you've figured out the root cause. Would you like to send a PR for it?

@steinybot
Copy link
Contributor Author

Sure thing. I started doing this then must have gotten distracted by something.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants