Hanxue
Hanxue

Reputation: 12766

sbt error when forking is enabled

Sbt produce an error when there is this line:

fork in run := true

in this build.scala file

The surrounding build.scala content

  lazy val scalafxDemos = Project(
    id = "scalafx-demos",
    base = file("scalafx-demos"),
    settings = scalafxSettings ++ Seq(
      libraryDependencies ++= Seq(
        scalatest % "test",
        junit % "test"),
      unmanagedListing,
      description := "The ScalaFX demonstrations",
      fork in run := true,
      fork in Test := true,
      parallelExecution in Test := false,
      // print junit-style XML for CI
      testOptions in Test <+= (target in Test) map {
        t => Tests.Argument(TestFrameworks.ScalaTest, "-u", "%s" format (t / "junitxmldir"))
      },

The error produced:

[error] /Users/hanxue/Github/scalafx/project/build.scala:113: overloaded method value in with alternatives:
[error]   (scope: sbt.Scope)sbt.SettingKey[Boolean] <and>
[error]   (c: sbt.ConfigKey)sbt.SettingKey[Boolean] <and>
[error]   (t: sbt.Scoped)sbt.SettingKey[Boolean] <and>
[error]   (p: sbt.Reference)sbt.SettingKey[Boolean]
[error]  cannot be applied to (run.type)
[error]       fork in run := true,
[error]            ^
[error] one error found
[error] (compile:compile) Compilation failed

I can avoid the error by changing the line to fork := true, though that does satisfy the intent of forking only in run and Test. How can I fix this without forcing everything else to be forked?

Upvotes: 1

Views: 887

Answers (1)

Mark Harrah
Mark Harrah

Reputation: 7019

That probably means run is coming from somewhere else. You might try an explicit Keys.run to see if this is the case.

Upvotes: 1

Related Questions