Skip to content

Commit

Permalink
Fast-fail on unsupported Scala versions
Browse files Browse the repository at this point in the history
  • Loading branch information
dwijnand committed Mar 20, 2020
1 parent 3db4630 commit f08f209
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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: _*)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [] }")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit f08f209

Please sign in to comment.