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 176c416
Show file tree
Hide file tree
Showing 9 changed files with 477 additions and 24 deletions.
39 changes: 33 additions & 6 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 @@ -195,6 +197,9 @@ 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 +285,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 +368,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 +437,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 +544,27 @@ 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")
},
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 +682,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,7 +706,7 @@ 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, compilerBridge213_next)
)
.configure(addSbtUtilScripted)

Expand All @@ -695,6 +721,7 @@ def bridges = {
compilerBridge211 / publishLocal,
compilerBridge212 / publishLocal,
compilerBridge213 / publishLocal,
compilerBridge213_next / publishLocal,
)
}
}
Expand Down
Loading

0 comments on commit 176c416

Please sign in to comment.