diff --git a/build.sbt b/build.sbt index 074f27cba..1c1d1e26e 100644 --- a/build.sbt +++ b/build.sbt @@ -1,4 +1,5 @@ import sbt.Def +import MimaSettings.mimaSettings lazy val kafkaVersion = "3.7.0" lazy val embeddedKafkaVersion = "3.7.0" // Should be the same as kafkaVersion, except for the patch part @@ -66,9 +67,10 @@ val excludeInferAny = { options: Seq[String] => options.filterNot(Set("-Xlint:in lazy val root = project .in(file(".")) .settings( - name := "zio-kafka", - publish / skip := true, - crossScalaVersions := Nil // https://www.scala-sbt.org/1.x/docs/Cross-Build.html#Cross+building+a+project+statefully + name := "zio-kafka", + publish / skip := true, + crossScalaVersions := Nil, // https://www.scala-sbt.org/1.x/docs/Cross-Build.html#Cross+building+a+project+statefully, + commands += lint ) .aggregate( zioKafka, @@ -104,6 +106,7 @@ lazy val zioKafka = .enablePlugins(BuildInfoPlugin) .settings(stdSettings("zio-kafka")) .settings(buildInfoSettings("zio.kafka")) + .settings(mimaSettings(failOnProblem = true)) .settings(enableZIO(enableStreaming = true)) .settings( libraryDependencies ++= Seq( @@ -126,6 +129,7 @@ lazy val zioKafkaTestkit = .dependsOn(zioKafka) .enablePlugins(BuildInfoPlugin) .settings(stdSettings("zio-kafka-testkit")) + .settings(mimaSettings(failOnProblem = false)) .settings( libraryDependencies ++= Seq( "dev.zio" %% "zio" % zioVersion.value, @@ -187,6 +191,7 @@ lazy val zioKafkaExample = addCommandAlias("fmt", "all scalafmtSbt scalafmt test:scalafmt") addCommandAlias("check", "all scalafmtSbtCheck scalafmtCheck test:scalafmtCheck") +addCommandAlias("mimaCheck", "+zioKafka/mimaReportBinaryIssues;+zioKafkaTestkit/mimaReportBinaryIssues") lazy val docs = project .in(file("zio-kafka-docs")) @@ -206,3 +211,8 @@ lazy val docs = project ) .enablePlugins(WebsitePlugin) .dependsOn(zioKafka, zioKafkaTestkit) + +lazy val lint = { + val defaultLint = zio.sbt.Commands.ComposableCommand.lint + defaultLint.copy(commandStrings = defaultLint.commandStrings :+ "mimaCheck").toCommand +} diff --git a/project/MimaSettings.scala b/project/MimaSettings.scala new file mode 100644 index 000000000..9252b1159 --- /dev/null +++ b/project/MimaSettings.scala @@ -0,0 +1,18 @@ +import com.typesafe.tools.mima.core.* +import com.typesafe.tools.mima.core.ProblemFilters.* +import com.typesafe.tools.mima.plugin.MimaKeys.* +import sbt.* +import sbt.Keys.{ name, organization } + +object MimaSettings { + lazy val bincompatVersionToCompare = "2.4.2" + + def mimaSettings(failOnProblem: Boolean) = + Seq( + mimaPreviousArtifacts := Set(organization.value %% name.value % bincompatVersionToCompare), + mimaBinaryIssueFilters ++= Seq( + exclude[Problem]("zio.kafka.consumer.internal.*") + ), + mimaFailOnProblem := failOnProblem + ) +} diff --git a/project/plugins.sbt b/project/plugins.sbt index 4d9438684..3cc823564 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -7,5 +7,6 @@ addSbtPlugin("dev.zio" % "zio-sbt-ci" % zioSbtVersion) addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.12.0") addSbtPlugin("org.typelevel" % "sbt-tpolecat" % "0.5.1") addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.9.16") +addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.3") resolvers ++= Resolver.sonatypeOssRepos("public")