Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable MiMa for Scala 3 #79

Merged
merged 1 commit into from
Dec 1, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 33 additions & 36 deletions core/src/main/scala/sbtspiewak/SpiewakPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 =>
Expand Down