[2.0.x] fix sjson downgrade (#9426)

Extend metabuild exclusion to all sbt-provided deps.
This commit is contained in:
Anatolii Kmetiuk 2026-07-13 11:25:40 +09:00 committed by Eugene Yokota
parent e00efb9d9c
commit c1b289c934
5 changed files with 93 additions and 1 deletions

View File

@ -3603,7 +3603,13 @@ object Classpaths {
o %% "librarymanagement-ivy",
o %% "util-logging",
o %% "util-position",
o %% "io"
o %% "io",
"com.eed3si9n" %% "sjson-new-core",
"com.eed3si9n" %% "gigahorse-core",
"com.typesafe" %% "ssl-config-core",
"org.reactivestreams" % "reactive-streams",
"org.slf4j" % "slf4j-api",
"com.typesafe" % "config",
)
if (isMeta && !force) excludes.toVector ++ sbtModulesExcludes
else excludes

View File

@ -0,0 +1,69 @@
ThisBuild / scalaVersion := "3.8.4"
ThisBuild / organization := "com.example"
libraryDependencies += "com.typesafe" % "config" % "1.4.5"
val checkMetabuildClasspath = taskKey[Unit]("Checks the effective metabuild classpath")
val checkProjectClasspath = taskKey[Unit]("Checks the project classpath")
checkMetabuildClasspath := Def.uncached {
val buildUnit = loadedBuild.value.units(thisProjectRef.value.build).unit
val classpath = buildUnit.plugins.pluginData.dependencyClasspath
val managedModules = classpath
.flatMap(_.get(Keys.moduleIDStr))
.map(Classpaths.moduleIdJsonKeyFormat.read)
.map(module => module.organization -> module.name)
.toSet
val launcherOwnedModules = Set(
"com.eed3si9n" -> "sjson-new-core_3",
"com.eed3si9n" -> "gigahorse-core_3",
"com.typesafe" -> "ssl-config-core_3",
"org.reactivestreams" -> "reactive-streams",
"org.slf4j" -> "slf4j-api",
"com.typesafe" -> "config",
)
val pluginModules = Set(
"ch.epfl.scala" -> "sbt-github-dependency-submission_sbt2_3",
"com.eed3si9n" -> "gigahorse-asynchttpclient_3",
"com.eed3si9n" -> "shaded-asynchttpclient",
)
val converter = buildUnit.converter
val launcherJars = classpath
.filter(_.get(Keys.moduleIDStr).isEmpty)
.map(entry => converter.toPath(entry.data).getFileName.toString)
val launcherJarNames = Set(
"sjson-new-core_3",
"gigahorse-core_3",
"ssl-config-core_3",
"reactive-streams",
"slf4j-api",
"config",
)
assert(
managedModules.intersect(launcherOwnedModules).isEmpty,
s"found plugin-managed sbt modules: ${managedModules.intersect(launcherOwnedModules)}",
)
assert(
pluginModules.subsetOf(managedModules),
s"missing plugin modules: ${pluginModules.diff(managedModules)}",
)
assert(
launcherJarNames.forall(name => launcherJars.count(_.startsWith(s"$name-")) == 1),
s"expected one launcher jar for each sbt module: $launcherJars",
)
}
checkProjectClasspath := Def.uncached {
val modules = (Compile / externalDependencyClasspath).value
.flatMap(_.get(Keys.moduleIDStr))
.map(Classpaths.moduleIdJsonKeyFormat.read)
assert(
modules.exists(module =>
module.organization == "com.typesafe" &&
module.name == "config" &&
module.revision == "1.4.5"
),
s"missing project dependency: $modules",
)
}

View File

@ -0,0 +1,6 @@
import sbt.*
import sbt.Keys.*
object Example {
lazy val settings = Seq(javaOptions += "-Dfoo=bar")
}

View File

@ -0,0 +1 @@
addSbtPlugin("ch.epfl.scala" % "sbt-github-dependency-submission" % "3.2.3")

View File

@ -0,0 +1,10 @@
# Issue 8207: a metabuild plugin must not downgrade sjson-new core.
# Loading this build exercises the metabuild compile, which summons
# the JsonFormat for String via the caching macro on javaOptions.
# When the plugin downgrades sjson-new core on the metabuild
# classpath, project load fails with a missing given. A successful
# load is the regression assertion.
> projects
> checkMetabuildClasspath
> checkProjectClasspath
> githubGenerateSnapshot {}