diff --git a/main/src/main/scala/sbt/plugins/SemanticdbPlugin.scala b/main/src/main/scala/sbt/plugins/SemanticdbPlugin.scala index c4f0718d7..7ea030558 100644 --- a/main/src/main/scala/sbt/plugins/SemanticdbPlugin.scala +++ b/main/src/main/scala/sbt/plugins/SemanticdbPlugin.scala @@ -55,8 +55,9 @@ object SemanticdbPlugin extends AutoPlugin { lazy val configurationSettings: Seq[Def.Setting[?]] = List( semanticdbTargetRoot := { + val converter = fileConverter.value val in = semanticdbIncludeInJar.value - if (in) classDirectory.value + if in then converter.toPath(backendOutput.value).toFile() else semanticdbTargetRoot.value }, semanticdbOptions --= Def.settingDyn { @@ -69,29 +70,24 @@ object SemanticdbPlugin extends AutoPlugin { }.value, semanticdbOptions ++= targetRootOptions(scalaVersion.value, semanticdbTargetRoot.value), - // todo: - // scalacOptions --= { - // Def - // .task { (configuration.value, semanticdbEnabled.value) } - // .flatMapTask { case (config, enabled) => - // if enabled then - // Def.task { - // (semanticdbOptions.?.all(ancestorConfigs(config)).value.flatten.flatten: Seq[String]) - // } - // else Def.task { (Nil: Seq[String]) } - // } - // .value - // }, - scalacOptions ++= { - if (semanticdbEnabled.value) - semanticdbOptions.value - else Seq.empty - } + scalacOptions := (Def.taskDyn { + val orig = scalacOptions.value + val config = configuration.value + if semanticdbEnabled.value then + Def.task { + val xs = + (orig diff semanticdbOptions.?.all(ancestorConfigs(config)).value.flatten.flatten) ++ + semanticdbOptions.value + println(xs.toString) + xs + } + else + Def.task { + orig + } + }).value, ) - @deprecated("use configurationSettings only", "1.5.0") - lazy val testSettings: Seq[Def.Setting[?]] = List() - def targetRootOptions(scalaVersion: String, targetRoot: File): Seq[String] = { if (ScalaInstance.isDotty(scalaVersion)) { Seq("-semanticdb-target", targetRoot.toString) diff --git a/sbt-app/src/sbt-test/project1/semanticdb/build.sbt b/sbt-app/src/sbt-test/project/semanticdb/build.sbt similarity index 66% rename from sbt-app/src/sbt-test/project1/semanticdb/build.sbt rename to sbt-app/src/sbt-test/project/semanticdb/build.sbt index 03ad56d26..5c7d9c1bc 100644 --- a/sbt-app/src/sbt-test/project1/semanticdb/build.sbt +++ b/sbt-app/src/sbt-test/project/semanticdb/build.sbt @@ -1,20 +1,17 @@ -ThisBuild / scalaVersion := "2.12.20" -ThisBuild / semanticdbEnabled := true -ThisBuild / semanticdbIncludeInJar := true +scalaVersion := "2.13.16" +semanticdbEnabled := true +semanticdbIncludeInJar := true // see https://github.com/sbt/sbt/issues/5886 lazy val check = taskKey[Unit]("Checks that scalacOptions have the same number of parameters across configurations") lazy val anyConfigInThisProject = ScopeFilter(configurations = inAnyConfiguration) lazy val Custom = config("custom").extend(Compile) -lazy val SystemTest = config("st").extend(IntegrationTest) lazy val root = (project in file(".")) - .configs(IntegrationTest, Custom, SystemTest) + .configs(Custom) .settings( - inConfig(IntegrationTest)(Defaults.testSettings ++ sbt.plugins.SemanticdbPlugin.configurationSettings), inConfig(Custom)(Defaults.configSettings ++ sbt.plugins.SemanticdbPlugin.configurationSettings), - inConfig(SystemTest)(Defaults.testSettings ++ sbt.plugins.SemanticdbPlugin.configurationSettings), check := { val scalacOptionsCountsAcrossConfigs = scalacOptions.?.all(anyConfigInThisProject) .value @@ -25,6 +22,12 @@ lazy val root = (project in file(".")) scalacOptionsCountsAcrossConfigs.size == 1, s"Configurations expected to have the same number of scalacOptions but found different numbers: $scalacOptionsCountsAcrossConfigs" ) - } + val converter = fileConverter.value + val p = converter.toPath((Compile / packageBin).value) + IO.unzip(p.toFile(), target.value / "extracted") + + val testp = converter.toPath((Test / packageBin).value) + IO.unzip(testp.toFile(), target.value / "test-extracted") + } ) diff --git a/sbt-app/src/sbt-test/project1/semanticdb/src/custom/scala/foo/Custom.scala b/sbt-app/src/sbt-test/project/semanticdb/src/custom/scala/foo/Custom.scala similarity index 100% rename from sbt-app/src/sbt-test/project1/semanticdb/src/custom/scala/foo/Custom.scala rename to sbt-app/src/sbt-test/project/semanticdb/src/custom/scala/foo/Custom.scala diff --git a/sbt-app/src/sbt-test/project1/semanticdb/src/main/scala/foo/Compile.scala b/sbt-app/src/sbt-test/project/semanticdb/src/main/scala/foo/Compile.scala similarity index 100% rename from sbt-app/src/sbt-test/project1/semanticdb/src/main/scala/foo/Compile.scala rename to sbt-app/src/sbt-test/project/semanticdb/src/main/scala/foo/Compile.scala diff --git a/sbt-app/src/sbt-test/project1/semanticdb/src/test/scala/foo/Test.scala b/sbt-app/src/sbt-test/project/semanticdb/src/test/scala/foo/Test.scala similarity index 100% rename from sbt-app/src/sbt-test/project1/semanticdb/src/test/scala/foo/Test.scala rename to sbt-app/src/sbt-test/project/semanticdb/src/test/scala/foo/Test.scala diff --git a/sbt-app/src/sbt-test/project/semanticdb/test b/sbt-app/src/sbt-test/project/semanticdb/test new file mode 100644 index 000000000..d25f63e9d --- /dev/null +++ b/sbt-app/src/sbt-test/project/semanticdb/test @@ -0,0 +1,5 @@ +> check + +$ exists target/**/extracted/META-INF/semanticdb/src/main/scala/foo/Compile.scala.semanticdb + +$ exists target/**/test-extracted/META-INF/semanticdb/src/test/scala/foo/Test.scala.semanticdb diff --git a/sbt-app/src/sbt-test/project1/semanticdb/src/it/scala/foo/IntegrationTest.scala b/sbt-app/src/sbt-test/project1/semanticdb/src/it/scala/foo/IntegrationTest.scala deleted file mode 100644 index ae24e8449..000000000 --- a/sbt-app/src/sbt-test/project1/semanticdb/src/it/scala/foo/IntegrationTest.scala +++ /dev/null @@ -1,3 +0,0 @@ -package foo - -object IntegrationTest diff --git a/sbt-app/src/sbt-test/project1/semanticdb/src/st/scala/foo/SystemTest.scala b/sbt-app/src/sbt-test/project1/semanticdb/src/st/scala/foo/SystemTest.scala deleted file mode 100644 index 9076368f1..000000000 --- a/sbt-app/src/sbt-test/project1/semanticdb/src/st/scala/foo/SystemTest.scala +++ /dev/null @@ -1,3 +0,0 @@ -package foo - -object SystemTest diff --git a/sbt-app/src/sbt-test/project1/semanticdb/test b/sbt-app/src/sbt-test/project1/semanticdb/test deleted file mode 100644 index 754edf028..000000000 --- a/sbt-app/src/sbt-test/project1/semanticdb/test +++ /dev/null @@ -1,16 +0,0 @@ -> compile -$ exists target/scala-2.12/classes/META-INF/semanticdb/src/main/scala/foo/Compile.scala.semanticdb - -> Test/compile -$ exists target/scala-2.12/test-classes/META-INF/semanticdb/src/test/scala/foo/Test.scala.semanticdb - -> IntegrationTest/compile -$ exists target/scala-2.12/it-classes/META-INF/semanticdb/src/it/scala/foo/IntegrationTest.scala.semanticdb - -> Custom/compile -$ exists target/scala-2.12/custom-classes/META-INF/semanticdb/src/custom/scala/foo/Custom.scala.semanticdb - -> SystemTest/compile -$ exists target/scala-2.12/st-classes/META-INF/semanticdb/src/st/scala/foo/SystemTest.scala.semanticdb - -> check