Skip to content

Commit f5853ee

Browse files
committed
Fix plugin publishing for Scala 2.13.0-2.13.2
1 parent 3d11361 commit f5853ee

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

plugin/package.mill

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,19 @@ trait Plugin extends CrossSbtModule with ScalafmtModule with release.ChiselPubli
2121
// The plugin is compiled for every minor Scala version
2222
override def crossFullScalaVersion = true
2323

24+
// This is a bit of a hack, but for some reason, Scala compilation crashes with -release 8 for
25+
// Scala 2.13.0-2.13.2. While -release 8 is what we want, -target:jvm-1.8 at least ensures the
26+
// bytecode is Java 8 compatible, and then the higher Scala versions compiled with -release 8 will
27+
// enforce the other guarantees of -release 8 (that we don't accidentally use Java APIs introduced
28+
// in newer JDKs).
29+
def releaseArg(scalaVersion: String): Seq[String] = {
30+
val badSet = Set("2.13.0", "2.13.1", "2.13.2")
31+
if (badSet.contains(scalaVersion)) Seq("-target:jvm-1.8")
32+
else Seq("-release", "8")
33+
}
34+
2435
// Does not use common options because -Wconf wasn't supported in early 2.13, nor was "-release:"
25-
override def scalacOptions = super.scalacOptions() ++ Seq("-release", "8")
36+
override def scalacOptions = super.scalacOptions() ++ releaseArg(crossScalaVersion)
2637

2738
def scalaLibraryIvy = v.scalaLibrary(crossScalaVersion)
2839
def scalaReflectIvy = v.scalaReflect(crossScalaVersion)

0 commit comments

Comments
 (0)