Merge pull request #8310 from eed3si9n/wip/fix-conraband

[2.x] fix: Set contrabandScala3enum to false
This commit is contained in:
eugene yokota 2025-09-28 22:22:32 -04:00 committed by GitHub
commit e99d0d9258
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 70 additions and 130 deletions

View File

@ -117,7 +117,7 @@ def testedBaseSettings: Seq[Setting[?]] =
val sbt20Plus = val sbt20Plus =
Seq( Seq(
"2.0.0-RC5", "2.0.0-RC4",
) )
val mimaSettings = mimaSettingsSince(sbt20Plus) val mimaSettings = mimaSettingsSince(sbt20Plus)
def mimaSettingsSince(versions: Seq[String]): Seq[Def.Setting[?]] = Def settings ( def mimaSettingsSince(versions: Seq[String]): Seq[Def.Setting[?]] = Def settings (
@ -141,6 +141,14 @@ def mimaSettingsSince(versions: Seq[String]): Seq[Def.Setting[?]] = Def settings
), ),
) )
val contrabandSettings: Seq[Def.Setting[?]] = Seq(
Compile / generateContrabands / sourceManaged := baseDirectory.value / "src" / "main" / "contraband-scala",
Compile / managedSourceDirectories +=
baseDirectory.value / "src" / "main" / "contraband-scala",
Compile / generateContrabands / contrabandScala3enum := false,
Compile / generateContrabands / contrabandFormatsForType := DatatypeConfig.getFormats,
)
val scriptedSbtMimaSettings = Def.settings(mimaPreviousArtifacts := Set()) val scriptedSbtMimaSettings = Def.settings(mimaPreviousArtifacts := Set())
lazy val sbtRoot: Project = (project in file(".")) lazy val sbtRoot: Project = (project in file("."))
@ -315,10 +323,7 @@ lazy val utilLogging = project
sjsonNewScalaJson.value, sjsonNewScalaJson.value,
), ),
testDependencies, testDependencies,
Compile / generateContrabands / contrabandCodecsDependencies := List(sjsonNewCore.value), contrabandSettings,
Compile / generateContrabands / sourceManaged := baseDirectory.value / "src" / "main" / "contraband-scala",
Compile / managedSourceDirectories +=
baseDirectory.value / "src" / "main" / "contraband-scala",
Compile / generateContrabands / contrabandFormatsForType := { tpe => Compile / generateContrabands / contrabandFormatsForType := { tpe =>
val old = (Compile / generateContrabands / contrabandFormatsForType).value val old = (Compile / generateContrabands / contrabandFormatsForType).value
val name = tpe.removeTypeParameters.name val name = tpe.removeTypeParameters.name
@ -358,12 +363,10 @@ lazy val utilCache = project
sjsonNewScalaJson.value, sjsonNewScalaJson.value,
sjsonNewMurmurhash.value sjsonNewMurmurhash.value
), ),
Compile / managedSourceDirectories += contrabandSettings,
baseDirectory.value / "src" / "main" / "contraband-scala",
Compile / generateContrabands / sourceManaged := baseDirectory.value / "src" / "main" / "contraband-scala",
Compile / generateContrabands / contrabandFormatsForType := ContrabandConfig.getFormats,
mimaSettings, mimaSettings,
mimaBinaryIssueFilters ++= Seq( mimaBinaryIssueFilters ++= Seq(
exclude[MissingClassProblem]("sbt.internal.util.ActionCacheError*"),
), ),
Test / fork := true, Test / fork := true,
) )
@ -411,10 +414,7 @@ lazy val testingProj = (project in file("testing"))
sjsonNewCore.value, sjsonNewCore.value,
), ),
conflictWarning := ConflictWarning.disable, conflictWarning := ConflictWarning.disable,
Compile / managedSourceDirectories += contrabandSettings,
baseDirectory.value / "src" / "main" / "contraband-scala",
Compile / generateContrabands / sourceManaged := baseDirectory.value / "src" / "main" / "contraband-scala",
Compile / generateContrabands / contrabandFormatsForType := ContrabandConfig.getFormats,
mimaSettings, mimaSettings,
mimaBinaryIssueFilters ++= Vector( mimaBinaryIssueFilters ++= Vector(
), ),
@ -476,9 +476,7 @@ lazy val runProj = (project in file("run"))
.settings( .settings(
testedBaseSettings, testedBaseSettings,
name := "Run", name := "Run",
Compile / managedSourceDirectories += contrabandSettings,
baseDirectory.value / "src" / "main" / "contraband-scala",
Compile / generateContrabands / sourceManaged := baseDirectory.value / "src" / "main" / "contraband-scala",
mimaSettings, mimaSettings,
mimaBinaryIssueFilters ++= Seq( mimaBinaryIssueFilters ++= Seq(
) )
@ -537,10 +535,7 @@ lazy val actionsProj = (project in file("main-actions"))
name := "Actions", name := "Actions",
libraryDependencies += sjsonNewScalaJson.value, libraryDependencies += sjsonNewScalaJson.value,
libraryDependencies ++= Seq(gigahorseApacheHttp, jline3Terminal), libraryDependencies ++= Seq(gigahorseApacheHttp, jline3Terminal),
Compile / managedSourceDirectories += contrabandSettings,
baseDirectory.value / "src" / "main" / "contraband-scala",
Compile / generateContrabands / sourceManaged := baseDirectory.value / "src" / "main" / "contraband-scala",
Compile / generateContrabands / contrabandFormatsForType := ContrabandConfig.getFormats,
// Test / fork := true, // Test / fork := true,
Test / classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.Flat, Test / classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.Flat,
mimaSettings, mimaSettings,
@ -564,10 +559,7 @@ lazy val protocolProj = (project in file("protocol"))
name := "Protocol", name := "Protocol",
libraryDependencies ++= Seq(sjsonNewScalaJson.value, sjsonNewCore.value, ipcSocket), libraryDependencies ++= Seq(sjsonNewScalaJson.value, sjsonNewCore.value, ipcSocket),
Compile / scalacOptions += "-source:3.7", Compile / scalacOptions += "-source:3.7",
Compile / managedSourceDirectories += contrabandSettings,
baseDirectory.value / "src" / "main" / "contraband-scala",
Compile / generateContrabands / sourceManaged := baseDirectory.value / "src" / "main" / "contraband-scala",
Compile / generateContrabands / contrabandFormatsForType := ContrabandConfig.getFormats,
mimaSettings, mimaSettings,
mimaBinaryIssueFilters ++= Seq( mimaBinaryIssueFilters ++= Seq(
) )
@ -586,10 +578,7 @@ lazy val commandProj = (project in file("main-command"))
sjsonNewScalaJson.value, sjsonNewScalaJson.value,
templateResolverApi templateResolverApi
), ),
Compile / managedSourceDirectories += contrabandSettings,
baseDirectory.value / "src" / "main" / "contraband-scala",
Compile / generateContrabands / sourceManaged := baseDirectory.value / "src" / "main" / "contraband-scala",
Compile / generateContrabands / contrabandFormatsForType := ContrabandConfig.getFormats,
mimaSettings, mimaSettings,
mimaBinaryIssueFilters ++= Vector( mimaBinaryIssueFilters ++= Vector(
), ),
@ -713,9 +702,7 @@ lazy val mainProj = (project in file("main"))
case v if v.startsWith("2.12.") => List() case v if v.startsWith("2.12.") => List()
case _ => List(scalaPar) case _ => List(scalaPar)
}), }),
Compile / managedSourceDirectories += contrabandSettings,
baseDirectory.value / "src" / "main" / "contraband-scala",
Compile / generateContrabands / sourceManaged := baseDirectory.value / "src" / "main" / "contraband-scala",
Test / testOptions += Tests Test / testOptions += Tests
.Argument(TestFrameworks.ScalaCheck, "-minSuccessfulTests", "1000"), .Argument(TestFrameworks.ScalaCheck, "-minSuccessfulTests", "1000"),
SettingKey[Boolean]("usePipelining") := false, SettingKey[Boolean]("usePipelining") := false,
@ -723,6 +710,8 @@ lazy val mainProj = (project in file("main"))
Compile / doc / sources := Nil, Compile / doc / sources := Nil,
mimaSettings, mimaSettings,
mimaBinaryIssueFilters ++= Vector( mimaBinaryIssueFilters ++= Vector(
exclude[MissingClassProblem]("sbt.internal.*"),
exclude[MissingFieldProblem]("sbt.internal.server.NetworkChannel.*"),
), ),
) )
.dependsOn(lmCore, lmIvy, lmCoursierShadedPublishing) .dependsOn(lmCore, lmIvy, lmCoursierShadedPublishing)
@ -1142,10 +1131,7 @@ lazy val lmCore = (project in file("lm-core"))
case v if v.startsWith("2.12.") => List("-Ywarn-unused:-locals,-explicits,-privates") case v if v.startsWith("2.12.") => List("-Ywarn-unused:-locals,-explicits,-privates")
case _ => List() case _ => List()
}), }),
Compile / managedSourceDirectories += contrabandSettings,
baseDirectory.value / "src" / "main" / "contraband-scala",
Compile / generateContrabands / sourceManaged := baseDirectory.value / "src" / "main" / "contraband-scala",
Compile / generateContrabands / contrabandFormatsForType := DatatypeConfig.getFormats,
// WORKAROUND sbt/sbt#2205 include managed sources in packageSrc // WORKAROUND sbt/sbt#2205 include managed sources in packageSrc
Compile / packageSrc / mappings ++= { Compile / packageSrc / mappings ++= {
val srcs = (Compile / managedSources).value val srcs = (Compile / managedSources).value
@ -1177,10 +1163,7 @@ lazy val lmIvy = (project in file("lm-ivy"))
scalacheck % Test, scalacheck % Test,
scalaVerify % Test, scalaVerify % Test,
), ),
Compile / managedSourceDirectories += contrabandSettings,
baseDirectory.value / "src" / "main" / "contraband-scala",
Compile / generateContrabands / sourceManaged := baseDirectory.value / "src" / "main" / "contraband-scala",
Compile / generateContrabands / contrabandFormatsForType := DatatypeConfig.getFormats,
Test / classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.Flat, Test / classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.Flat,
mimaSettings, mimaSettings,
) )

View File

@ -5,12 +5,11 @@
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY
package sbt.internal.util package sbt.internal.util
/** value for logging options like color */ /** value for logging options like color */
enum LogOption { sealed abstract class LogOption extends Serializable
case Always
case Never
case Auto
}
object LogOption { object LogOption {
case object Always extends LogOption
case object Never extends LogOption
case object Auto extends LogOption
} }

View File

@ -11,13 +11,12 @@ package sbt.librarymanagement
* `Quiet` only displays errors. * `Quiet` only displays errors.
* `Default` uses the current log level of `update` task. * `Default` uses the current log level of `update` task.
*/ */
enum UpdateLogging { sealed abstract class UpdateLogging extends Serializable
case Full
case DownloadOnly
case Quiet
case Default
}
object UpdateLogging { object UpdateLogging {
case object Full extends UpdateLogging
case object DownloadOnly extends UpdateLogging
case object Quiet extends UpdateLogging
case object Default extends UpdateLogging
} }

View File

@ -4,15 +4,14 @@
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY
package sbt.internal.sona package sbt.internal.sona
enum DeploymentState { sealed abstract class DeploymentState extends Serializable
case PENDING
case VALIDATING
case VALIDATED
case PUBLISHING
case PUBLISHED
case FAILED
}
object DeploymentState { object DeploymentState {
case object PENDING extends DeploymentState
case object VALIDATING extends DeploymentState
case object VALIDATED extends DeploymentState
case object PUBLISHING extends DeploymentState
case object PUBLISHED extends DeploymentState
case object FAILED extends DeploymentState
} }

View File

@ -4,11 +4,10 @@
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY
package sbt package sbt
enum ConnectionType { sealed abstract class ConnectionType extends Serializable
/** This uses Unix domain socket on POSIX, and named pipe on Windows. */
case Local
case Tcp
}
object ConnectionType { object ConnectionType {
/** This uses Unix domain socket on POSIX, and named pipe on Windows. */
case object Local extends ConnectionType
case object Tcp extends ConnectionType
} }

View File

@ -4,10 +4,9 @@
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY
package sbt package sbt
enum ServerAuthentication { sealed abstract class ServerAuthentication extends Serializable
case Token
}
object ServerAuthentication { object ServerAuthentication {
case object Token extends ServerAuthentication
} }

View File

@ -1,53 +0,0 @@
import sbt.contraband.ast.*
import sbt.contraband.CodecCodeGen
object ContrabandConfig {
/** Extract the only type parameter from a TpeRef */
def oneArg(tpe: Type): Type = {
val pat = s"""${tpe.removeTypeParameters.name}[<\\[](.+?)[>\\]]""".r
val pat(arg0) = tpe.name
NamedType(arg0 split '.' toList)
}
/** Extract the two type parameters from a TpeRef */
def twoArgs(tpe: Type): List[Type] = {
val pat = s"""${tpe.removeTypeParameters.name}[<\\[](.+?), (.+?)[>\\]]""".r
val pat(arg0, arg1) = tpe.name
NamedType(arg0 split '.' toList) :: NamedType(arg1 split '.' toList) :: Nil
}
/** Codecs that were manually written. */
val myCodecs: PartialFunction[String, Type => List[String]] = {
// TODO: These are handled by BasicJsonProtocol, and sbt-contraband should handle them by default, imo
case "Option" | "Set" | "scala.Vector" => { tpe =>
getFormats(oneArg(tpe))
}
case "Map" | "Tuple2" | "scala.Tuple2" => { tpe =>
twoArgs(tpe).flatMap(getFormats)
}
case "Int" | "Long" => { _ =>
Nil
}
case "sbt.testing.Status" => { _ =>
"sbt.internal.testing.StatusFormats" :: Nil
}
case "scalajson.ast.unsafe.JValue" | "sjsonnew.shaded.scalajson.ast.unsafe.JValue" => { _ =>
"sbt.internal.util.codec.JValueFormats" :: Nil
}
case "xsbti.HashedVirtualFileRef" => { _ =>
"sbt.internal.util.codec.HashedVirtualFileRefFormats" :: Nil
}
case "java.nio.ByteBuffer" => { _ =>
"sbt.internal.util.codec.ByteBufferFormats" :: Nil
}
}
/** Returns the list of formats required to encode the given `TpeRef`. */
val getFormats: Type => List[String] =
CodecCodeGen.extensibleFormatsForType {
case tpe: Type if myCodecs isDefinedAt tpe.removeTypeParameters.name =>
myCodecs(tpe.removeTypeParameters.name)(tpe)
case other => CodecCodeGen.formatsForType(other)
}
}

View File

@ -62,6 +62,22 @@ object DatatypeConfig {
"sbt.librarymanagement.ConfigRefFormats" :: Nil "sbt.librarymanagement.ConfigRefFormats" :: Nil
} }
case "sbt.testing.Status" => { _ =>
"sbt.internal.testing.StatusFormats" :: Nil
}
case "scalajson.ast.unsafe.JValue" | "sjsonnew.shaded.scalajson.ast.unsafe.JValue" => { _ =>
"sbt.internal.util.codec.JValueFormats" :: Nil
}
case "xsbti.HashedVirtualFileRef" => { _ =>
"sbt.internal.util.codec.HashedVirtualFileRefFormats" :: Nil
}
case "java.nio.ByteBuffer" => { _ =>
"sbt.internal.util.codec.ByteBufferFormats" :: Nil
}
// TODO: These are handled by BasicJsonProtocol, and sbt-datatype should handle them by default, imo // TODO: These are handled by BasicJsonProtocol, and sbt-datatype should handle them by default, imo
case "Option" | "Set" | "scala.Vector" => { tpe => case "Option" | "Set" | "scala.Vector" => { tpe =>
getFormats(oneArg(tpe)) getFormats(oneArg(tpe))

View File

@ -5,13 +5,12 @@
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY
package sbt.protocol.testing package sbt.protocol.testing
/** Testing result */ /** Testing result */
enum TestResult { sealed abstract class TestResult extends Serializable
case Empty
case Passed
case Failed
case Error
}
object TestResult { object TestResult {
case object Empty extends TestResult
case object Passed extends TestResult
case object Failed extends TestResult
case object Error extends TestResult
} }