sbt icon indicating copy to clipboard operation
sbt copied to clipboard

IntegrationTest settings should be compatible/friendly for AutoPlugin usage

Open ghost opened this issue 10 years ago • 4 comments

I am trying to write an AutoPlugin that provides some source generation in IntegrationTest configuration. The task added by the AutoPlugin gets removed. Here is a minimum Build.scala needed to reproduce the problem

import sbt.Keys._
import sbt._

object TestP extends AutoPlugin {
  override def requires = JvmPlugin

  override def projectSettings: Seq[Setting[_]] = Seq(
    sourceGenerators in IntegrationTest <+= Def.task {
      println("source generated in plugin")
      Nil
    }
  )
}

object Build extends Build {
  lazy val test123 = Project(id = "test123", base = file("."))
    .configs(IntegrationTest)
    .enablePlugins(TestP)
    .settings(Defaults.itSettings: _*)
    .settings(sourceGenerators in IntegrationTest <+= Def.task {
      println("source generated in settings")
      Nil
    })
}

Produces

4:09 $ sbt it:test
[info] Loading project definition from /Users/user/code/test123/project
[info] Set current project to test123 (in build file:/Users/user/code/test123/)
source generated in settings
[success] Total time: 0 s, completed Jul 21, 2015 4:09:32 PM

If you look at the second last line it only prints out "source generated in settings" but not the "source generated in plugin".

ghost avatar Jul 21 '15 13:07 ghost

The issue is actually in Defaults.itSettings. These are added after the autoplugin settings, and the notion of "itSettings" should probably be translated into Autoplugins, so you can depend on their existence. The workaround right would be to put the itSettings into your autoplugin and not specify them manually on projects.

Going to retitle this.

jsuereth avatar Jul 24 '15 13:07 jsuereth

I am closing this due to inactivity, and also there's a workaround posted.

eed3si9n avatar Sep 01 '18 00:09 eed3si9n

I'm facing the same problem.. are you going to do something with this?

sergevoloshyn avatar Sep 26 '18 22:09 sergevoloshyn

I'll reopen this. Would you like to try for a pull request on this? I think the first step would be to make a plugin under https://github.com/sbt/sbt/tree/develop/main/src/main/scala/sbt/plugins.

eed3si9n avatar Sep 28 '18 10:09 eed3si9n