From 9dfcb2af1870e267d8759e39e38cf3c5b12abef4 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Wed, 1 Dec 2021 19:27:02 +0000 Subject: [PATCH] Enable MiMa for Scala 3 --- .../main/scala/sbtspiewak/SpiewakPlugin.scala | 69 +++++++++---------- 1 file changed, 33 insertions(+), 36 deletions(-) diff --git a/core/src/main/scala/sbtspiewak/SpiewakPlugin.scala b/core/src/main/scala/sbtspiewak/SpiewakPlugin.scala index 0bdb4a1..12ad08a 100644 --- a/core/src/main/scala/sbtspiewak/SpiewakPlugin.scala +++ b/core/src/main/scala/sbtspiewak/SpiewakPlugin.scala @@ -470,53 +470,50 @@ object SpiewakPlugin extends AutoPlugin { }, mimaPreviousArtifacts := { - if (!isDotty.value) { - val current = version.value - val org = organization.value - val n = moduleName.value + val current = version.value + val org = organization.value + val n = moduleName.value - val TagBase = """^(\d+)\.(\d+).*"""r - val TagBase(major, minor) = baseVersion.value + val TagBase = """^(\d+)\.(\d+).*"""r + val TagBase(major, minor) = baseVersion.value - val isPre = major.toInt == 0 + val isPre = major.toInt == 0 - if (sbtPlugin.value || !crossProjectPlatform.?.value.map(_.identifier == "jvm").getOrElse(true)) { - Set.empty - } else { - val tags = Try("git tag --list".!!.split("\n").map(_.trim)).getOrElse(new Array[String](0)) + if (sbtPlugin.value || !crossProjectPlatform.?.value.map(_.identifier == "jvm").getOrElse(true)) { + Set.empty + } else { + val tags = Try("git tag --list".!!.split("\n").map(_.trim)).getOrElse(new Array[String](0)) - // in semver, we allow breakage in minor releases if major is 0, otherwise not - val Pattern = if (isPre || !strictSemVer.value) - s"^v($major\\.$minor\\.\\d+)$$".r - else - s"^v($major\\.\\d+\\.\\d+)$$".r + // in semver, we allow breakage in minor releases if major is 0, otherwise not + val Pattern = if (isPre || !strictSemVer.value) + s"^v($major\\.$minor\\.\\d+)$$".r + else + s"^v($major\\.\\d+\\.\\d+)$$".r - val versions = tags collect { - case Pattern(version) => version - } - - val notCurrent = versions.filterNot(current ==) + val versions = tags collect { + case Pattern(version) => version + } - val FullVersion = """^(\d+)\.(\d+)\.(\d+)$""".r - val reduced = versionIntroduced.value.get(CrossVersion.binaryScalaVersion(scalaVersion.value)) match { - case Some(FullVersion(boundMaj, boundMin, boundRev)) => - // we assume you don't want more than 1000 versions per component - val boundOrd = boundMaj.toInt * 1000 * 1000 + boundMin.toInt * 1000 + boundRev.toInt + val notCurrent = versions.filterNot(current ==) - notCurrent filter { - case FullVersion(maj, min, rev) => - (maj.toInt * 1000 * 1000 + min.toInt * 1000 + rev.toInt) >= boundOrd - } + val FullVersion = """^(\d+)\.(\d+)\.(\d+)$""".r + val reduced = versionIntroduced.value.get(CrossVersion.binaryScalaVersion(scalaVersion.value)) match { + case Some(FullVersion(boundMaj, boundMin, boundRev)) => + // we assume you don't want more than 1000 versions per component + val boundOrd = boundMaj.toInt * 1000 * 1000 + boundMin.toInt * 1000 + boundRev.toInt - case None => - notCurrent - } + notCurrent filter { + case FullVersion(maj, min, rev) => + (maj.toInt * 1000 * 1000 + min.toInt * 1000 + rev.toInt) >= boundOrd + } - reduced.map(v => org % s"${n}_${CrossVersion.binaryScalaVersion(scalaVersion.value)}" % v).toSet + case None => + notCurrent } - } else { - Set.empty // mima doesn't support Scala 3 yet + + reduced.map(v => org % s"${n}_${CrossVersion.binaryScalaVersion(scalaVersion.value)}" % v).toSet } + }, pomPostProcess := { node =>