mirror of https://github.com/sbt/sbt.git
fix: Set contrabandScala3enum to false
This commit is contained in:
parent
d44b2c8720
commit
d10f6ee54e
56
build.sbt
56
build.sbt
|
|
@ -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())
|
||||
|
||||
lazy val sbtRoot: Project = (project in file("."))
|
||||
|
|
@ -315,10 +323,7 @@ lazy val utilLogging = project
|
|||
sjsonNewScalaJson.value,
|
||||
),
|
||||
testDependencies,
|
||||
Compile / generateContrabands / contrabandCodecsDependencies := List(sjsonNewCore.value),
|
||||
Compile / generateContrabands / sourceManaged := baseDirectory.value / "src" / "main" / "contraband-scala",
|
||||
Compile / managedSourceDirectories +=
|
||||
baseDirectory.value / "src" / "main" / "contraband-scala",
|
||||
contrabandSettings,
|
||||
Compile / generateContrabands / contrabandFormatsForType := { tpe =>
|
||||
val old = (Compile / generateContrabands / contrabandFormatsForType).value
|
||||
val name = tpe.removeTypeParameters.name
|
||||
|
|
@ -358,10 +363,7 @@ lazy val utilCache = project
|
|||
sjsonNewScalaJson.value,
|
||||
sjsonNewMurmurhash.value
|
||||
),
|
||||
Compile / managedSourceDirectories +=
|
||||
baseDirectory.value / "src" / "main" / "contraband-scala",
|
||||
Compile / generateContrabands / sourceManaged := baseDirectory.value / "src" / "main" / "contraband-scala",
|
||||
Compile / generateContrabands / contrabandFormatsForType := ContrabandConfig.getFormats,
|
||||
contrabandSettings,
|
||||
mimaSettings,
|
||||
mimaBinaryIssueFilters ++= Seq(
|
||||
),
|
||||
|
|
@ -411,10 +413,7 @@ lazy val testingProj = (project in file("testing"))
|
|||
sjsonNewCore.value,
|
||||
),
|
||||
conflictWarning := ConflictWarning.disable,
|
||||
Compile / managedSourceDirectories +=
|
||||
baseDirectory.value / "src" / "main" / "contraband-scala",
|
||||
Compile / generateContrabands / sourceManaged := baseDirectory.value / "src" / "main" / "contraband-scala",
|
||||
Compile / generateContrabands / contrabandFormatsForType := ContrabandConfig.getFormats,
|
||||
contrabandSettings,
|
||||
mimaSettings,
|
||||
mimaBinaryIssueFilters ++= Vector(
|
||||
),
|
||||
|
|
@ -476,9 +475,7 @@ lazy val runProj = (project in file("run"))
|
|||
.settings(
|
||||
testedBaseSettings,
|
||||
name := "Run",
|
||||
Compile / managedSourceDirectories +=
|
||||
baseDirectory.value / "src" / "main" / "contraband-scala",
|
||||
Compile / generateContrabands / sourceManaged := baseDirectory.value / "src" / "main" / "contraband-scala",
|
||||
contrabandSettings,
|
||||
mimaSettings,
|
||||
mimaBinaryIssueFilters ++= Seq(
|
||||
)
|
||||
|
|
@ -537,10 +534,7 @@ lazy val actionsProj = (project in file("main-actions"))
|
|||
name := "Actions",
|
||||
libraryDependencies += sjsonNewScalaJson.value,
|
||||
libraryDependencies ++= Seq(gigahorseApacheHttp, jline3Terminal),
|
||||
Compile / managedSourceDirectories +=
|
||||
baseDirectory.value / "src" / "main" / "contraband-scala",
|
||||
Compile / generateContrabands / sourceManaged := baseDirectory.value / "src" / "main" / "contraband-scala",
|
||||
Compile / generateContrabands / contrabandFormatsForType := ContrabandConfig.getFormats,
|
||||
contrabandSettings,
|
||||
// Test / fork := true,
|
||||
Test / classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.Flat,
|
||||
mimaSettings,
|
||||
|
|
@ -564,10 +558,7 @@ lazy val protocolProj = (project in file("protocol"))
|
|||
name := "Protocol",
|
||||
libraryDependencies ++= Seq(sjsonNewScalaJson.value, sjsonNewCore.value, ipcSocket),
|
||||
Compile / scalacOptions += "-source:3.7",
|
||||
Compile / managedSourceDirectories +=
|
||||
baseDirectory.value / "src" / "main" / "contraband-scala",
|
||||
Compile / generateContrabands / sourceManaged := baseDirectory.value / "src" / "main" / "contraband-scala",
|
||||
Compile / generateContrabands / contrabandFormatsForType := ContrabandConfig.getFormats,
|
||||
contrabandSettings,
|
||||
mimaSettings,
|
||||
mimaBinaryIssueFilters ++= Seq(
|
||||
)
|
||||
|
|
@ -586,10 +577,7 @@ lazy val commandProj = (project in file("main-command"))
|
|||
sjsonNewScalaJson.value,
|
||||
templateResolverApi
|
||||
),
|
||||
Compile / managedSourceDirectories +=
|
||||
baseDirectory.value / "src" / "main" / "contraband-scala",
|
||||
Compile / generateContrabands / sourceManaged := baseDirectory.value / "src" / "main" / "contraband-scala",
|
||||
Compile / generateContrabands / contrabandFormatsForType := ContrabandConfig.getFormats,
|
||||
contrabandSettings,
|
||||
mimaSettings,
|
||||
mimaBinaryIssueFilters ++= Vector(
|
||||
),
|
||||
|
|
@ -713,9 +701,7 @@ lazy val mainProj = (project in file("main"))
|
|||
case v if v.startsWith("2.12.") => List()
|
||||
case _ => List(scalaPar)
|
||||
}),
|
||||
Compile / managedSourceDirectories +=
|
||||
baseDirectory.value / "src" / "main" / "contraband-scala",
|
||||
Compile / generateContrabands / sourceManaged := baseDirectory.value / "src" / "main" / "contraband-scala",
|
||||
contrabandSettings,
|
||||
Test / testOptions += Tests
|
||||
.Argument(TestFrameworks.ScalaCheck, "-minSuccessfulTests", "1000"),
|
||||
SettingKey[Boolean]("usePipelining") := false,
|
||||
|
|
@ -1142,10 +1128,7 @@ lazy val lmCore = (project in file("lm-core"))
|
|||
case v if v.startsWith("2.12.") => List("-Ywarn-unused:-locals,-explicits,-privates")
|
||||
case _ => List()
|
||||
}),
|
||||
Compile / managedSourceDirectories +=
|
||||
baseDirectory.value / "src" / "main" / "contraband-scala",
|
||||
Compile / generateContrabands / sourceManaged := baseDirectory.value / "src" / "main" / "contraband-scala",
|
||||
Compile / generateContrabands / contrabandFormatsForType := DatatypeConfig.getFormats,
|
||||
contrabandSettings,
|
||||
// WORKAROUND sbt/sbt#2205 include managed sources in packageSrc
|
||||
Compile / packageSrc / mappings ++= {
|
||||
val srcs = (Compile / managedSources).value
|
||||
|
|
@ -1177,10 +1160,7 @@ lazy val lmIvy = (project in file("lm-ivy"))
|
|||
scalacheck % Test,
|
||||
scalaVerify % Test,
|
||||
),
|
||||
Compile / managedSourceDirectories +=
|
||||
baseDirectory.value / "src" / "main" / "contraband-scala",
|
||||
Compile / generateContrabands / sourceManaged := baseDirectory.value / "src" / "main" / "contraband-scala",
|
||||
Compile / generateContrabands / contrabandFormatsForType := DatatypeConfig.getFormats,
|
||||
contrabandSettings,
|
||||
Test / classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.Flat,
|
||||
mimaSettings,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
@ -62,6 +62,22 @@ object DatatypeConfig {
|
|||
"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
|
||||
case "Option" | "Set" | "scala.Vector" => { tpe =>
|
||||
getFormats(oneArg(tpe))
|
||||
|
|
|
|||
Loading…
Reference in New Issue