Skip to content

Commit

Permalink
Provide an improved DelegatingReporter
Browse files Browse the repository at this point in the history
**Problem**
We need to surface the code action from Scala 2.13.x.

**Solution**
This adds an alternative DelegatingReporter implementation as a
resource. The ZincComponentManager can then substitute the source
for 2.13.12 onwards.
  • Loading branch information
eed3si9n committed Jul 8, 2023
1 parent 151de24 commit 87eebce
Show file tree
Hide file tree
Showing 10 changed files with 499 additions and 27 deletions.
61 changes: 53 additions & 8 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Util._
import ZincBuildUtil._
import Dependencies._
import localzinc.Scripted, Scripted._
import com.typesafe.tools.mima.core._, ProblemFilters._
Expand Down Expand Up @@ -82,6 +82,8 @@ Global / concurrentRestrictions += Tags.limit(Tags.Test, 4)
// Global / semanticdbVersion := "4.5.9"
ThisBuild / Test / fork := true
Global / excludeLintKeys += ideSkipProject
Global / resolvers += "scala-integration" at
"https://scala-ci.typesafe.com/artifactory/scala-integration/"

def baseSettings: Seq[Setting[_]] = Seq(
testOptions += Tests.Argument(TestFrameworks.ScalaCheck, "-w", "1", "-verbosity", "2"),
Expand Down Expand Up @@ -131,6 +133,7 @@ def addBaseSettingsAndTestDeps(p: Project): Project =
// zincRoot is now only 2.12 (2.11.x is not supported anymore)
lazy val aggregated: Seq[ProjectReference] = compilerInterface.projectRefs ++
compilerBridge.projectRefs ++
Seq(compilerBridge213_next: ProjectReference) ++
zincApiInfo.projectRefs ++
zincBenchmarks.projectRefs ++
zincClasspath.projectRefs ++
Expand Down Expand Up @@ -195,6 +198,13 @@ lazy val zinc = (projectMatrix in (zincRootPath / "zinc"))
BuildInfoKey.map(compilerBridge213 / scalaVersion)("scalaVersion213" -> _._2),
BuildInfoKey.map(compilerBridge213 / scalaInstance)("scalaJars213" -> _._2.allJars.toList),
BuildInfoKey.map(compilerBridge213 / Compile / classDirectory)("classDirectory213" -> _._2),
BuildInfoKey.map(compilerBridge213_next / scalaVersion)("scalaVersion213_next" -> _._2),
BuildInfoKey.map(compilerBridge213_next / scalaInstance)(
"scalaJars213_next" -> _._2.allJars.toList
),
BuildInfoKey.map(compilerBridge213_next / Compile / classDirectory)(
"classDirectory213_next" -> _._2
),
),
Test / classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.Flat,
// so we have full access to com.sun.tools.javac on JDK 17
Expand Down Expand Up @@ -280,7 +290,7 @@ lazy val zincPersist = (projectMatrix in internalPath / "zinc-persist")
}),
Test / classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.Flat,
mimaSettings,
mimaBinaryIssueFilters ++= Util.excludeInternalProblems,
mimaBinaryIssueFilters ++= ZincBuildUtil.excludeInternalProblems,
mimaBinaryIssueFilters ++= Seq(
exclude[IncompatibleMethTypeProblem]("xsbti.*"),
exclude[ReversedMissingMethodProblem]("xsbti.*"),
Expand Down Expand Up @@ -363,7 +373,7 @@ lazy val zincCore = (projectMatrix in internalPath / "zinc-core")
name := "zinc Core",
compileOrder := sbt.CompileOrder.Mixed,
mimaSettings,
mimaBinaryIssueFilters ++= Util.excludeInternalProblems,
mimaBinaryIssueFilters ++= ZincBuildUtil.excludeInternalProblems,
mimaBinaryIssueFilters ++= Seq(
exclude[IncompatibleMethTypeProblem]("xsbti.*"),
exclude[ReversedMissingMethodProblem]("xsbti.*"),
Expand Down Expand Up @@ -432,7 +442,7 @@ lazy val zincCompileCore = (projectMatrix in internalPath / "zinc-compile-core")
Compile / managedSourceDirectories += (Compile / generateContrabands / sourceManaged).value,
Compile / generateContrabands / sourceManaged := (internalPath / "zinc-compile-core" / "src" / "main" / "contraband-java").getAbsoluteFile,
mimaSettings,
mimaBinaryIssueFilters ++= Util.excludeInternalProblems,
mimaBinaryIssueFilters ++= ZincBuildUtil.excludeInternalProblems,
)
.defaultAxes(VirtualAxis.jvm, VirtualAxis.scalaPartialVersion(scala212))
.jvmPlatform(scalaVersions = List(scala212, scala213))
Expand Down Expand Up @@ -539,6 +549,30 @@ lazy val compilerBridge211 = compilerBridge.jvm(scala211)
lazy val compilerBridge212 = compilerBridge.jvm(scala212)
lazy val compilerBridge213 = compilerBridge.jvm(scala213)

lazy val compilerBridge213_next = (project in (file(".sbt") / "matrix" / "compilerBridge2_13_next"))
.dependsOn(compilerInterface.jvm(false))
.settings(
scalaVersion := scala213_next,
autoScalaLibrary := false,
baseSettings,
compilerVersionDependentScalacOptions,
// We need this for import Compat._
Compile / scalacOptions --= Seq("-Ywarn-unused-import", "-Xfatal-warnings"),
libraryDependencies += scalaCompiler.value % "provided",
exportJars := true,
Compile / unmanagedResourceDirectories ++= (compilerBridge213 / Compile / unmanagedResourceDirectories).value,
Compile / unmanagedSourceDirectories ++= (compilerBridge213 / Compile / unmanagedSourceDirectories).value,
Compile / sources := {
val xs = (Compile / sources).value
(xs.filterNot { x => x.getName() == "DelegatingReporter.scala" }) ++
Seq(
(compilerBridge213 / Compile / scalaSource).value.getParentFile() / "resources" / "scala-2.13.12" / "DelegatingReporter.scala"
)
},
publishLocal / skip := false,
publish / skip := true,
)

/**
* Tests for the compiler bridge.
* This is split into a separate subproject because testing introduces more dependencies
Expand Down Expand Up @@ -656,7 +690,7 @@ lazy val zincClassfile = (projectMatrix in internalPath / "zinc-classfile")
exclude[IncompatibleResultTypeProblem]("sbt.internal.inc.IndexBasedZipOps.*"),
exclude[ReversedMissingMethodProblem]("sbt.internal.inc.IndexBasedZipOps.*"),
),
mimaBinaryIssueFilters ++= Util.excludeInternalProblems,
mimaBinaryIssueFilters ++= ZincBuildUtil.excludeInternalProblems,
)
.defaultAxes(VirtualAxis.jvm, VirtualAxis.scalaPartialVersion(scala212))
.jvmPlatform(scalaVersions = scala212_213)
Expand All @@ -680,21 +714,31 @@ lazy val zincScripted = (projectMatrix in internalPath / "zinc-scripted")
.defaultAxes(VirtualAxis.jvm, VirtualAxis.scalaPartialVersion(scala212))
.jvmPlatform(scalaVersions = List(scala212))
.configure(
_.dependsOn(compilerBridge210, compilerBridge211, compilerBridge212, compilerBridge213)
_.dependsOn(
compilerBridge210,
compilerBridge211,
compilerBridge212,
compilerBridge213,
)
)
.configure(addSbtUtilScripted)

lazy val zincScripted212 = zincScripted.jvm(scala212)

def bridges = {
if (sys.props("java.specification.version") == "1.8") {
List(compilerBridge210 / publishLocal, compilerBridge211 / publishLocal)
List(
compilerBridge210 / publishLocal,
compilerBridge211 / publishLocal,
compilerBridge213_next / publishLocal,
)
} else {
List(
compilerBridge210 / publishLocal,
compilerBridge211 / publishLocal,
compilerBridge212 / publishLocal,
compilerBridge213 / publishLocal,
compilerBridge213_next / publishLocal,
)
}
}
Expand All @@ -703,7 +747,8 @@ val publishBridges = taskKey[Unit]("")
val crossTestBridges = taskKey[Unit]("")

publishBridges := Def.task(()).dependsOn(bridges: _*).value
crossTestBridges := (compilerBridgeTest / Test / test).dependsOn(publishBridges).value
crossTestBridges := (compilerBridgeTest / Test / test)
.dependsOn(publishBridges).value

addCommandAlias(
"runBenchmarks", {
Expand Down
Loading

0 comments on commit 87eebce

Please sign in to comment.