fix: Fix sbt 1.x cross building

**Problem**
Under -Xlint, sbt 1.x complains that nowarn isn't doing anything.

**Solution**
Bring back Wconf for sbt 1.x cross building.
This commit is contained in:
Eugene Yokota 2025-08-21 07:18:51 +02:00
parent 1de603fb2f
commit 0c9408d312
4 changed files with 43 additions and 5 deletions

View File

@ -1004,11 +1004,9 @@ object Defaults extends BuildCommon {
},
scalacOptions := {
val old = scalacOptions.value
if (
sbtPlugin.value && VersionNumber(scalaVersion.value)
.matchesSemVer(SemanticSelector("=2.12 >=2.12.13"))
)
old ++ Seq("-Wconf:cat=unused-nowarn:s", "-Xsource:3")
if sbtPlugin.value && VersionNumber(scalaVersion.value)
.matchesSemVer(SemanticSelector("=2.12"))
then old ++ Seq("-Wconf:cat=unused-nowarn:s", "-Xsource:3")
else old
},
persistJarClasspath :== true,

View File

@ -0,0 +1,22 @@
organization := "com.example"
version := "0.1.0-SNAPSHOT"
lazy val root = (project in file("."))
.aggregate(plugin.projectRefs*)
lazy val plugin = (projectMatrix in file("plugin"))
.enablePlugins(SbtPlugin)
.settings(
name := "example-plugin",
scalacOptions ++= {
if (scalaBinaryVersion.value == "2.12")
Seq("-Xlint", "-Werror")
else Seq("-Werror")
},
(pluginCrossBuild / sbtVersion) := {
scalaBinaryVersion.value match
case "2.12" => "1.5.8"
case _ => "2.0.0-RC3"
},
)
.jvmPlatform(scalaVersions = Seq("3.7.2", "2.12.20"))

View File

@ -0,0 +1,16 @@
package example
import sbt._
// import Keys.*
object APlugin extends AutoPlugin {
object autoImport {
val a = taskKey[Int]("")
}
import autoImport._
override def projectSettings = Seq(
a := 2
)
}

View File

@ -0,0 +1,2 @@
> projects
> compile