Skip to content

Commit

Permalink
Support scala 3.0.0 final (scalapb#1144)
Browse files Browse the repository at this point in the history
  • Loading branch information
timothyklim authored May 14, 2021
1 parent a86f014 commit ac380d5
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
SCALA_VERSION: ${{matrix.scala}}
strategy:
matrix:
scala: [2_12, 2_13, 3_0_0_RC3]
scala: [2_12, 2_13, 3]
script: [mima, e2e, proptest]
include:
- scala: 2_12
Expand Down
42 changes: 21 additions & 21 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import com.typesafe.tools.mima.core._
import BuildHelper._
import Dependencies._

val protobufCompilerVersion = "3.13.0"
val protobufCompilerVersion = "3.15.8"

val MimaPreviousVersion = "0.11.0"

Expand Down Expand Up @@ -56,7 +56,7 @@ lazy val runtime = (projectMatrix in file("scalapb-runtime"))
),
testFrameworks += new TestFramework("munit.Framework"),
Compile / unmanagedResourceDirectories += (LocalRootProject / baseDirectory).value / "protobuf",
scalacOptions ++= (if (!isDotty.value)
scalacOptions ++= (if (!isScala3.value)
Seq(
"-P:silencer:globalFilters=avaGenerateEqualsAndHash in class .* is deprecated",
"-P:silencer:lineContentFilters=import scala.collection.compat._"
Expand All @@ -70,7 +70,7 @@ lazy val runtime = (projectMatrix in file("scalapb-runtime"))
)
)
.jvmPlatform(
scalaVersions = Seq(Scala212, Scala213, Dotty),
scalaVersions = Seq(Scala212, Scala213, Scala3),
settings = Seq(
libraryDependencies ++= Seq(
protobufJava
Expand All @@ -86,7 +86,7 @@ lazy val runtime = (projectMatrix in file("scalapb-runtime"))
)
)
.jsPlatform(
scalaVersions = Seq(Scala212, Scala213, Dotty),
scalaVersions = Seq(Scala212, Scala213, Scala3),
settings = Seq(
libraryDependencies += protobufRuntimeScala.value,
scalajsSourceMaps,
Expand Down Expand Up @@ -120,7 +120,7 @@ lazy val grpcRuntime = (projectMatrix in file("scalapb-runtime-grpc"))
.defaultAxes()
.dependsOn(runtime)
.settings(commonSettings)
.jvmPlatform(scalaVersions = Seq(Scala212, Scala213, Dotty))
.jvmPlatform(scalaVersions = Seq(Scala212, Scala213, Scala3))
.settings(
name := "scalapb-runtime-grpc",
testFrameworks += new TestFramework("munit.Framework"),
Expand Down Expand Up @@ -159,7 +159,7 @@ lazy val compilerPlugin = (projectMatrix in file("compiler-plugin"))
Compiler.generateVersionFile,
Compiler.generateEncodingFile
)
.jvmPlatform(Seq(Scala212, Scala213, Dotty))
.jvmPlatform(Seq(Scala212, Scala213, Scala3))

lazy val compilerPluginJVM2_12 = compilerPlugin.jvm(Scala212)

Expand Down Expand Up @@ -219,7 +219,7 @@ lazy val protocGenScalaNativeImage =
lazy val proptest = (projectMatrix in file("proptest"))
.defaultAxes()
.dependsOn(compilerPlugin % "compile->compile;test->test", runtime, grpcRuntime)
.jvmPlatform(scalaVersions = Seq(Scala212, Scala213, Dotty))
.jvmPlatform(scalaVersions = Seq(Scala212, Scala213, Scala3))
.settings(commonSettings)
.settings(
publishArtifact := false,
Expand All @@ -232,12 +232,12 @@ lazy val proptest = (projectMatrix in file("proptest"))
scalaTest.value % "test",
scalaTestPlusScalaCheck.value % "test"
),
scalacOptions ++= (if (!isDotty.value)
scalacOptions ++= (if (!isScala3.value)
Seq(
"-P:silencer:lineContentFilters=import scala.collection.compat._"
)
else Nil),
libraryDependencies ++= (if (!isDotty.value)
libraryDependencies ++= (if (!isScala3.value)
Seq("org.scala-lang" % "scala-compiler" % scalaVersion.value)
else
Seq(
Expand All @@ -261,9 +261,9 @@ lazy val lenses = (projectMatrix in file("lenses"))
),
mimaPreviousArtifacts := Set("com.thesamet.scalapb" %% "lenses" % MimaPreviousVersion)
)
.jvmPlatform(scalaVersions = Seq(Scala212, Scala213, Dotty))
.jvmPlatform(scalaVersions = Seq(Scala212, Scala213, Scala3))
.jsPlatform(
scalaVersions = Seq(Scala212, Scala213, Dotty),
scalaVersions = Seq(Scala212, Scala213, Scala3),
settings = scalajsSourceMaps ++ Seq(
scalaJSLinkerConfig ~= (_.withModuleKind(ModuleKind.CommonJSModule))
)
Expand Down Expand Up @@ -297,11 +297,11 @@ lazy val e2eGrpc = (projectMatrix in file("e2e-grpc"))
.defaultAxes()
.dependsOn(runtime, grpcRuntime)
.enablePlugins(LocalCodeGenPlugin)
.jvmPlatform(Seq(Scala212, Scala213, Dotty))
.jvmPlatform(Seq(Scala212, Scala213, Scala3))
.settings(e2eCommonSettings)
.settings(
libraryDependencies += (grpcProtocGen asProtocPlugin),
scalacOptions ++= (if (!isDotty.value)
scalacOptions ++= (if (!isScala3.value)
Seq(
"-P:silencer:pathFilters=ServerReflectionGrpc.scala;ReflectionProto.scala",
"-P:silencer:lineContentFilters=import com.thesamet.pb.MisplacedMapper.weatherMapper"
Expand All @@ -326,14 +326,14 @@ lazy val e2eWithJava = (projectMatrix in file("e2e-withjava"))
.enablePlugins(LocalCodeGenPlugin)
.settings(e2eCommonSettings)
.settings(
scalacOptions ++= (if (!isDotty.value)
scalacOptions ++= (if (!isScala3.value)
Seq(
"-P:silencer:lineContentFilters=import com.thesamet.pb.MisplacedMapper.weatherMapper"
)
else Nil)
)
.jvmPlatform(
Seq(Scala212, Scala213, Dotty),
Seq(Scala212, Scala213, Scala3),
settings = Seq(
Compile / PB.targets := Seq(
PB.gens.java(versions.protobuf) -> (Compile / sourceManaged).value,
Expand All @@ -345,7 +345,7 @@ lazy val e2eWithJava = (projectMatrix in file("e2e-withjava"))
)
)
.jsPlatform(
Seq(Scala212, Scala213, Dotty),
Seq(Scala212, Scala213, Scala3),
settings = Seq(
Compile / PB.includePaths += (ThisBuild / baseDirectory).value / "protobuf",
Compile / PB.targets := Seq(
Expand All @@ -359,25 +359,25 @@ lazy val e2e = (projectMatrix in file("e2e"))
.dependsOn(runtime, e2eWithJava)
.enablePlugins(LocalCodeGenPlugin)
.jvmPlatform(
Seq(Scala212, Scala213, Dotty),
Seq(Scala212, Scala213, Scala3),
settings = Seq(
Test / unmanagedSourceDirectories += (Test / scalaSource).value.getParentFile / (if (
isDotty.value
isScala3.value
)
"scalajvm-3"
else
"scalajvm-2")
)
)
.jsPlatform(
Seq(Scala212, Scala213, Dotty),
Seq(Scala212, Scala213, Scala3),
settings = Seq(
Compile / PB.includePaths += (ThisBuild / baseDirectory).value / "protobuf"
)
)
.settings(e2eCommonSettings)
.settings(
scalacOptions ++= (if (!isDotty.value)
scalacOptions ++= (if (!isScala3.value)
Seq(
"-P:silencer:globalFilters=value deprecatedInt32 in class TestDeprecatedFields is deprecated",
"-P:silencer:pathFilters=custom_options_use;CustomAnnotationProto.scala;TestDeprecatedFields.scala",
Expand Down Expand Up @@ -422,7 +422,7 @@ lazy val docs = project
mdocVariables := Map(
"scalapb" -> "0.11.1",
"scalapb_latest" -> "0.11.1",
"scala3" -> Dependencies.Dotty,
"scala3" -> Dependencies.Scala3,
"sbt_protoc" -> "1.0.3",
"sbt_dotty" -> "0.5.3",
"protoc" -> "3.15.6",
Expand Down
15 changes: 7 additions & 8 deletions project/BuildHelper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -47,30 +47,29 @@ object BuildHelper {

val scalac3Options = Seq(
"-language:implicitConversions",
"-source",
"3.0"
"-source:3.0-migration"
)

val scala2Settings = Seq()

val scala3Settings = Seq()

def isDotty = Def.setting[Boolean] { scalaVersion.value.startsWith("3.") }
def isScala3 = Def.setting[Boolean] { scalaVersion.value.startsWith("3.") }

def commonSettings = Seq(
scalacOptions ++= commonScalacOptions ++ (if (isDotty.value) scalac3Options
scalacOptions ++= commonScalacOptions ++ (if (isScala3.value) scalac3Options
else scalac2Options),
libraryDependencies ++= (if (!isDotty.value) Dependencies.silencer else Nil),
libraryDependencies ++= (if (!isScala3.value) Dependencies.silencer else Nil),
libraryDependencies += Dependencies.scalaCollectionCompat.value
.cross(CrossVersion.for3Use2_13),
Compile / unmanagedSourceDirectories += (Compile / scalaSource).value.getParentFile / (if (
isDotty.value
isScala3.value
)
"scala-3"
else
"scala-2"),
Test / unmanagedSourceDirectories += (Test / scalaSource).value.getParentFile / (if (
isDotty.value
isScala3.value
)
"scala-3"
else
Expand Down Expand Up @@ -119,7 +118,7 @@ object BuildHelper {
.Process("git rev-parse HEAD")
.lineStream_!
.head
val flag = if (isDotty.value) "-scalajs-mapSourceURI" else "-P:scalajs:mapSourceURI"
val flag = if (isScala3.value) "-scalajs-mapSourceURI" else "-P:scalajs:mapSourceURI"
s"$flag:$a->$g/"
}
}
16 changes: 8 additions & 8 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,30 @@ import Keys._
object Dependencies {
object versions {
val grpc = "1.37.0"
val protobuf = "3.15.6"
val protobuf = "3.15.8"
val silencer = "1.7.3"
val collectionCompat = "2.4.4"
val coursier = "2.0.16"
val protocGen = "0.9.2"
val protobufRuntimeScala = "0.8.11"
val protobufRuntimeScala = "0.8.12"
val commonsCodec = "1.15"

// For testing
val annotationApi = "1.3.2"
val cats = "2.6.0"
val mockito = "3.2.0"
val cats = "2.6.1"
val mockito = "3.2.4"
val munit = "0.7.26"
val scalaTest = "3.2.8"
val scalaTest = "3.2.9"
val scalaTestPlusMockito = "3.1.0.0"
val scalaTestPlusScalaCheck = "3.2.8.0"
val utest = "0.7.9"
val scalaTestPlusScalaCheck = "3.2.9.0"
val utest = "0.7.10"
}

val Scala212 = "2.12.13"

val Scala213 = "2.13.5"

val Dotty = "3.0.0-RC3"
val Scala3 = "3.0.0"

val silencer = Seq(
sbt.compilerPlugin(
Expand Down

0 comments on commit ac380d5

Please sign in to comment.