Skip to content

Commit

Permalink
Rework doc and repl scalacOptions (#3653)
Browse files Browse the repository at this point in the history
  • Loading branch information
regadas authored Mar 3, 2021
1 parent 6f9cd32 commit 11cc428
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
5 changes: 2 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,7 @@ val commonSettings = Def
scalaVersion := "2.13.5",
crossScalaVersions := Seq("2.12.13", scalaVersion.value),
scalacOptions ++= Scalac.commonsOptions.value,
Compile / doc / scalacOptions --= Seq("-release", "8"),
Compile / doc / scalacOptions ++= Scalac.compileDocOptions.value,
Compile / doc / scalacOptions := Scalac.docOptions.value,
javacOptions ++= Seq("-source", "1.8", "-target", "1.8", "-Xlint:unchecked"),
javacOptions in (Compile, doc) := Seq("-source", "1.8"),
// protobuf-lite is an older subset of protobuf-java and causes issues
Expand Down Expand Up @@ -978,7 +977,7 @@ lazy val `scio-repl`: Project = project
.settings(assemblySettings)
.settings(macroSettings)
.settings(
scalacOptions --= Seq("-release", "8"),
scalacOptions := Scalac.replOptions.value,
libraryDependencies ++= Seq(
"org.scala-lang.modules" %% "scala-collection-compat" % scalaCollectionCompatVersion,
"org.apache.beam" % "beam-runners-direct-java" % beamVersion,
Expand Down
25 changes: 16 additions & 9 deletions project/ScalacOptions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ object Scalac {
// see: https://tpolecat.github.io/2017/04/25/scalac-flags.html
val parallelism = math.min(math.max(4, java.lang.Runtime.getRuntime().availableProcessors()), 16)
val baseOptions = Def.setting {
val base = List(
List(
"-target:jvm-1.8",
"-deprecation", // Emit warning and location for usages of deprecated APIs.
"-feature", // Emit warning and location for usages of features that should be imported explicitly.
Expand Down Expand Up @@ -63,11 +63,6 @@ object Scalac {
"-Ybackend-parallelism",
parallelism.toString
)

VersionNumber(sys.props("java.version")) match {
case v if v.matchesSemVer(SemanticSelector(">1.8")) => base ++ List("-release", "8")
case _ => base
}
}

val scalaVersionOptions = Def.setting {
Expand All @@ -93,14 +88,26 @@ object Scalac {
}
}

val commonsOptions = Def.setting(baseOptions.value ++ scalaVersionOptions.value)
val jvmVersionOptions = Def.setting {
VersionNumber(sys.props("java.version")) match {
case v if v.matchesSemVer(SemanticSelector(">1.8")) => List("-release", "8")
case _ => Nil
}
}

val commonsOptions =
Def.setting(baseOptions.value ++ scalaVersionOptions.value ++ jvmVersionOptions.value)

val compileDocOptions = Def.setting {
val base = List("-skip-packages", "org.apache")
val docOptions = Def.setting {
val base =
baseOptions.value ++ scalaVersionOptions.value ++ List("-skip-packages", "org.apache")

VersionNumber(scalaVersion.value) match {
case v if v.matchesSemVer(SemanticSelector("2.12.x")) => base ++ List("-no-java-comments")
case _ => base
}
}

val replOptions = Def.setting(baseOptions.value ++ scalaVersionOptions.value)

}

0 comments on commit 11cc428

Please sign in to comment.