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 #13

Merged
merged 1 commit into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
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
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)
)
}
Loading