0

Consider the following sbt plugin definition which "overrides" the default "it" configuration to extend the Test configuration (for reasons discussed at How to make "test" classes available in the "it" (integration test) configuration?)

import sbt._
import Keys._

object MyPlugin extends AutoPlugin {
  private lazy val IntegrationTest = config("it") extend(Test)

  override def projectSettings: Seq[Setting[_]] = Seq(
    ...
  ) ++ inConfig(IntegrationTest)(Defaults.itSettings)

  override def projectConfigurations: Seq[Configuration] = IntegrationTest :: Nil
}

While this seems to work in general, it "masks" the run task. See the following sbt output from a project which uses the above described plugin:

[myproject] $ inspect run
[info] Input task: Unit
[info] Description:
[info]  Runs a main class, passing along arguments provided on the command 
line.
[info] Provided by:
[info]  {file://myproject/}myproject/it:run
[info] Defined at:
[info]  (sbt.Defaults) Defaults.scala:307
...

Note it:run instead of compile:run. Somehow the re-definition of the "it" config seems to re-define/mask the run task. This does not happen if I choose e.g. "fun" instead of "it". I'm using sbt 0.13.15.

Any idea what's going on here and how to prevent the run task from being masked?

pfm
  • 6,210
  • 4
  • 39
  • 44
Martin Studer
  • 2,213
  • 1
  • 18
  • 23
  • Could this be related to http://stackoverflow.com/questions/33243981/how-can-i-override-tasks-run-and-runmain-in-sbt-to-use-my-own-forkopti/33244341#33244341? – Martin Studer Apr 28 '17 at 12:39
  • They same actually happens if I simply do `override def projectConfigurations: Seq[Configuration] = Seq(Configurations.IntegrationTest extend (Test))` instead of redefining my own `lazy val IntegrationTest` – Martin Studer May 02 '17 at 14:47

1 Answers1

0

The problem was a missing plugin dependency on sbt.plugins.JvmPlugin which provides the mechanisms to compile/test/run/package Java/Scala projects (see http://www.scala-sbt.org/0.13/docs/Using-Plugins.html).

Adding

override def requires: Plugins = plugins.JvmPlugin

seems to resolve the problem.

Martin Studer
  • 2,213
  • 1
  • 18
  • 23