Skip to content

Commit 11cc428

Browse files
authored
Rework doc and repl scalacOptions (spotify#3653)
1 parent 6f9cd32 commit 11cc428

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

build.sbt

+2-3
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,7 @@ val commonSettings = Def
144144
scalaVersion := "2.13.5",
145145
crossScalaVersions := Seq("2.12.13", scalaVersion.value),
146146
scalacOptions ++= Scalac.commonsOptions.value,
147-
Compile / doc / scalacOptions --= Seq("-release", "8"),
148-
Compile / doc / scalacOptions ++= Scalac.compileDocOptions.value,
147+
Compile / doc / scalacOptions := Scalac.docOptions.value,
149148
javacOptions ++= Seq("-source", "1.8", "-target", "1.8", "-Xlint:unchecked"),
150149
javacOptions in (Compile, doc) := Seq("-source", "1.8"),
151150
// protobuf-lite is an older subset of protobuf-java and causes issues
@@ -978,7 +977,7 @@ lazy val `scio-repl`: Project = project
978977
.settings(assemblySettings)
979978
.settings(macroSettings)
980979
.settings(
981-
scalacOptions --= Seq("-release", "8"),
980+
scalacOptions := Scalac.replOptions.value,
982981
libraryDependencies ++= Seq(
983982
"org.scala-lang.modules" %% "scala-collection-compat" % scalaCollectionCompatVersion,
984983
"org.apache.beam" % "beam-runners-direct-java" % beamVersion,

project/ScalacOptions.scala

+16-9
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ object Scalac {
2222
// see: https://tpolecat.github.io/2017/04/25/scalac-flags.html
2323
val parallelism = math.min(math.max(4, java.lang.Runtime.getRuntime().availableProcessors()), 16)
2424
val baseOptions = Def.setting {
25-
val base = List(
25+
List(
2626
"-target:jvm-1.8",
2727
"-deprecation", // Emit warning and location for usages of deprecated APIs.
2828
"-feature", // Emit warning and location for usages of features that should be imported explicitly.
@@ -63,11 +63,6 @@ object Scalac {
6363
"-Ybackend-parallelism",
6464
parallelism.toString
6565
)
66-
67-
VersionNumber(sys.props("java.version")) match {
68-
case v if v.matchesSemVer(SemanticSelector(">1.8")) => base ++ List("-release", "8")
69-
case _ => base
70-
}
7166
}
7267

7368
val scalaVersionOptions = Def.setting {
@@ -93,14 +88,26 @@ object Scalac {
9388
}
9489
}
9590

96-
val commonsOptions = Def.setting(baseOptions.value ++ scalaVersionOptions.value)
91+
val jvmVersionOptions = Def.setting {
92+
VersionNumber(sys.props("java.version")) match {
93+
case v if v.matchesSemVer(SemanticSelector(">1.8")) => List("-release", "8")
94+
case _ => Nil
95+
}
96+
}
97+
98+
val commonsOptions =
99+
Def.setting(baseOptions.value ++ scalaVersionOptions.value ++ jvmVersionOptions.value)
97100

98-
val compileDocOptions = Def.setting {
99-
val base = List("-skip-packages", "org.apache")
101+
val docOptions = Def.setting {
102+
val base =
103+
baseOptions.value ++ scalaVersionOptions.value ++ List("-skip-packages", "org.apache")
100104

101105
VersionNumber(scalaVersion.value) match {
102106
case v if v.matchesSemVer(SemanticSelector("2.12.x")) => base ++ List("-no-java-comments")
103107
case _ => base
104108
}
105109
}
110+
111+
val replOptions = Def.setting(baseOptions.value ++ scalaVersionOptions.value)
112+
106113
}

0 commit comments

Comments
 (0)