From f08f2098d376055565f88121d2be8f426daf3b39 Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Fri, 20 Mar 2020 20:54:13 +0000 Subject: [PATCH] Fast-fail on unsupported Scala versions --- .../main/scala/com/typesafe/tools/mima/lib/MiMaLib.scala | 9 ++++++++- .../typesafe/tools/mima/lib/CollectProblemsTest.scala | 2 +- .../com/typesafe/tools/mima/plugin/MimaPlugin.scala | 3 ++- .../scala/com/typesafe/tools/mima/plugin/SbtMima.scala | 4 ++-- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/core/src/main/scala/com/typesafe/tools/mima/lib/MiMaLib.scala b/core/src/main/scala/com/typesafe/tools/mima/lib/MiMaLib.scala index 94aca688..5bd5d923 100644 --- a/core/src/main/scala/com/typesafe/tools/mima/lib/MiMaLib.scala +++ b/core/src/main/scala/com/typesafe/tools/mima/lib/MiMaLib.scala @@ -11,7 +11,14 @@ import scala.tools.nsc.classpath.AggregateClassPath import scala.tools.nsc.mima.ClassPathAccessors import scala.tools.nsc.util.ClassPath -final class MiMaLib(cp: Seq[File], log: Logging = ConsoleLogging) { +final class MiMaLib(cp: Seq[File], scalaVersion: String, log: Logging = ConsoleLogging) { + locally { + scalaVersion.take(5) match { + case "2.11." | "2.12." | "2.13." => () // ok + case _ => throw new IllegalArgumentException(s"MiMa supports Scala 2.10-2.13, not $scalaVersion") + } + } + val classpath = AggregateClassPath.createAggregate(cp.flatMap(pathToClassPath(_)) :+ Config.baseClassPath: _*) diff --git a/functional-tests/src/main/scala/com/typesafe/tools/mima/lib/CollectProblemsTest.scala b/functional-tests/src/main/scala/com/typesafe/tools/mima/lib/CollectProblemsTest.scala index 9065a4b4..9536b77c 100644 --- a/functional-tests/src/main/scala/com/typesafe/tools/mima/lib/CollectProblemsTest.scala +++ b/functional-tests/src/main/scala/com/typesafe/tools/mima/lib/CollectProblemsTest.scala @@ -11,7 +11,7 @@ object CollectProblemsTest { // Called via reflection from TestsPlugin def runTest(cp: Array[File], testName: String, oldJarOrDir: File, newJarOrDir: File, baseDir: File, oracleFile: File): Unit = { - val mima = new MiMaLib(cp) + val mima = new MiMaLib(cp, scala.util.Properties.versionNumberString) val configFile = new File(baseDir, "test.conf") val configFallback = ConfigFactory.parseString("filter { problems = [] }") diff --git a/sbtplugin/src/main/scala/com/typesafe/tools/mima/plugin/MimaPlugin.scala b/sbtplugin/src/main/scala/com/typesafe/tools/mima/plugin/MimaPlugin.scala index 19e099bf..1643d2ba 100644 --- a/sbtplugin/src/main/scala/com/typesafe/tools/mima/plugin/MimaPlugin.scala +++ b/sbtplugin/src/main/scala/com/typesafe/tools/mima/plugin/MimaPlugin.scala @@ -77,6 +77,7 @@ object MimaPlugin extends AutoPlugin { val previousClassfiles = mimaPreviousClassfiles.value val currentClassfiles = mimaCurrentClassfiles.value val cp = (fullClasspath in mimaFindBinaryIssues).value + val sv = scalaVersion.value val log = new SbtLogger(s) if (previousClassfiles eq NoPreviousClassfiles) { @@ -87,7 +88,7 @@ object MimaPlugin extends AutoPlugin { } previousClassfiles.iterator.map { case (moduleId, prevClassfiles) => - moduleId -> SbtMima.runMima(prevClassfiles, currentClassfiles, cp, mimaCheckDirection.value, log) + moduleId -> SbtMima.runMima(prevClassfiles, currentClassfiles, cp, mimaCheckDirection.value, sv, log) } } diff --git a/sbtplugin/src/main/scala/com/typesafe/tools/mima/plugin/SbtMima.scala b/sbtplugin/src/main/scala/com/typesafe/tools/mima/plugin/SbtMima.scala index b7018b2f..c5590642 100644 --- a/sbtplugin/src/main/scala/com/typesafe/tools/mima/plugin/SbtMima.scala +++ b/sbtplugin/src/main/scala/com/typesafe/tools/mima/plugin/SbtMima.scala @@ -21,8 +21,8 @@ import scala.util.matching._ object SbtMima { /** Runs MiMa and returns a two lists of potential binary incompatibilities, the first for backward compatibility checking, and the second for forward checking. */ - def runMima(prev: File, curr: File, cp: Classpath, dir: String, log: Logging): (List[Problem], List[Problem]) = { - val mimaLib = new MiMaLib(Attributed.data(cp), log) + def runMima(prev: File, curr: File, cp: Classpath, dir: String, scalaVersion: String, log: Logging): (List[Problem], List[Problem]) = { + val mimaLib = new MiMaLib(Attributed.data(cp), scalaVersion, log) def checkBC = mimaLib.collectProblems(prev, curr) def checkFC = mimaLib.collectProblems(curr, prev) dir match {