Delete checkPluginCross task. Add sourceGenerators for PluginCross (#8897)

This commit is contained in:
kenji yoshida 2026-03-12 03:40:49 +09:00 committed by GitHub
parent 5fb9f3c5fa
commit d6e6d28f87
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 additions and 10 deletions

View File

@ -53,7 +53,6 @@ val excludeLint = SettingKey[Set[Def.KeyedInitialize[?]]]("excludeLintKeys")
Global / excludeLint := (Global / excludeLint).?.value.getOrElse(Set.empty)
Global / excludeLint += Utils.componentID
Global / excludeLint += scriptedBufferLog
Global / excludeLint += checkPluginCross
Global / excludeLint += nativeImageJvm
Global / excludeLint += nativeImageVersion
@ -709,12 +708,18 @@ lazy val mainProj = (project in file("main"))
.settings(
testedBaseSettings,
name := "Main",
checkPluginCross := {
val sv = scalaVersion.value
val f = baseDirectory.value / "src" / "main" / "scala" / "sbt" / "PluginCross.scala"
if (sv.startsWith("2.12") && !IO.readLines(f).exists(_.contains(s""""$sv""""))) {
sys.error(s"PluginCross.scala does not match up with the scalaVersion $sv")
}
Compile / sourceGenerators += task {
val f = (Compile / sourceManaged).value / "sbt" / "PluginCrossExtra.scala"
IO.write(
f,
s"""|package sbt
|
|private[sbt] trait PluginCrossExtra { self: PluginCross.type =>
| def scala3: String = "${Dependencies.scala3}"
|}
|""".stripMargin
)
Seq(f)
},
libraryDependencies ++=
Seq(

View File

@ -24,7 +24,7 @@ import ProjectExtra.{ extract, setProject }
/**
* Module responsible for plugin cross building.
*/
private[sbt] object PluginCross {
private[sbt] object PluginCross extends PluginCrossExtra {
lazy val pluginSwitch: Command = {
def switchParser(state: State): Parser[(String, String)] = {
lazy val switchArgs = token(NotSpace.examples()) ~ (token(
@ -102,7 +102,7 @@ private[sbt] object PluginCross {
case VersionNumber(Seq(0, 12, _*), _, _) => "2.9.2"
case VersionNumber(Seq(0, 13, _*), _, _) => "2.10.7"
case VersionNumber(Seq(1, 0, _*), _, _) => "2.12.21"
case VersionNumber(Seq(2, _*), _, _) => "3.8.2"
case VersionNumber(Seq(2, _*), _, _) => scala3
case _ => sys.error(s"Unsupported sbt binary version: $sv")
}
}

View File

@ -6,7 +6,6 @@ object Dependencies {
val scala213 = "2.13.16"
val scala3 = "3.8.2"
val scala212 = "2.12.21"
val checkPluginCross = settingKey[Unit]("Make sure scalaVersion match up")
val baseScalaVersion = scala3
def nightlyVersion: Option[String] =
sys.env.get("BUILD_VERSION") orElse sys.props.get("sbt.build.version")