Skip to content

Commit

Permalink
Enable MiMa
Browse files Browse the repository at this point in the history
  • Loading branch information
mdedetrich committed Aug 3, 2023
1 parent e6de8cf commit 6207da1
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 8 deletions.
18 changes: 10 additions & 8 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ val pekkoHttpVersion = "1.0.0"
val jawnVersion = "1.5.0"
val scalaTestVersion = "3.2.16"

ThisBuild / crossScalaVersions := Seq(scala212Version, scala213Version, scala3Version)
ThisBuild / scalaVersion := scala213Version
ThisBuild / organization := "org.mdedetrich"
ThisBuild / mimaFailOnNoPrevious := false // Set this to true when we start caring about binary compatibility
ThisBuild / versionScheme := Some(VersionScheme.EarlySemVer)
ThisBuild / crossScalaVersions := Seq(scala212Version, scala213Version, scala3Version)
ThisBuild / scalaVersion := scala213Version
ThisBuild / organization := "org.mdedetrich"
ThisBuild / versionScheme := Some(VersionScheme.EarlySemVer)

lazy val streamJson = project
.in(file("stream-json"))
Expand Down Expand Up @@ -65,9 +64,11 @@ lazy val parent = project
.dependsOn(httpJson, httpCirce)
.aggregate(streamJson, httpJson, streamCirce, httpCirce, tests)
.settings(
publish / skip := true,
publishSigned / skip := true,
publishLocal / skip := true
name := "pekko-streams-circe",
mimaPreviousArtifacts := Set.empty,
publish / skip := true,
publishSigned / skip := true,
publishLocal / skip := true
)

lazy val tests = project
Expand All @@ -85,6 +86,7 @@ lazy val tests = project
publishSigned / skip := true,
publishLocal / skip := true
)
.disablePlugins(MimaPlugin)

ThisBuild / scalacOptions ++= Seq(
"-release:8",
Expand Down
35 changes: 35 additions & 0 deletions project/Mima.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import com.typesafe.tools.mima.plugin.MimaKeys._
import com.typesafe.tools.mima.plugin.MimaPlugin
import sbt.{AutoPlugin, CrossVersion}
import sbt.Keys._
import sbt._

import scala.collection.immutable

object Mima extends AutoPlugin {
override def requires = MimaPlugin

override def trigger = allRequirements

private def expandVersions(major: Long, minor: Long, patches: immutable.Seq[Int]): immutable.Seq[String] =
patches.map(patch => s"$major.$minor.$patch")
private def previousArtifacts(projectName: String, organization: String, version: String): Set[sbt.ModuleID] = {
val Some((major, minor)) = CrossVersion.partialVersion(version)
val currentPatchVersion = version.split("\\.").last
val stripRegex = """(\d+)(.*)""".r

val currentPatchVersionStripped = currentPatchVersion match {
case stripRegex(v, _) => v.toInt
}

if (currentPatchVersionStripped == 0)
Set(organization %% projectName % s"$major.$minor.0")
else
expandVersions(major, minor, 0 until currentPatchVersionStripped).map(v => organization %% projectName % v).toSet
}

override lazy val projectSettings = Seq(
mimaReportSignatureProblems := true,
mimaPreviousArtifacts := previousArtifacts(name.value, organization.value, version.value)
)
}

0 comments on commit 6207da1

Please sign in to comment.