diff --git a/project/plugins.sbt b/project/plugins.sbt index d417a058..21480e70 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -5,6 +5,7 @@ addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "2.0.3") addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2") addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.13.0") addSbtPlugin("com.github.cb372" % "sbt-explicit-dependencies" % "0.3.1") +addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.4") // Versioning and Release Plugins addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.12.0") diff --git a/zio-sbt-ecosystem/src/main/scala/zio/sbt/MimaSettings.scala b/zio-sbt-ecosystem/src/main/scala/zio/sbt/MimaSettings.scala new file mode 100644 index 00000000..5da3b4b1 --- /dev/null +++ b/zio-sbt-ecosystem/src/main/scala/zio/sbt/MimaSettings.scala @@ -0,0 +1,40 @@ +/* + * Copyright 2022-2023 dev.zio + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package zio.sbt + +import sbt.Keys._ +import sbt._ + +import com.typesafe.tools.mima.plugin.MimaKeys._ + +import zio.sbt.BuildAssertions.Keys.isScalaJVM + +import sbtdynver.DynVerPlugin.autoImport.previousStableVersion + +trait MimaSettings { + + lazy val checkMima: TaskKey[Unit] = taskKey[Unit]("Checks binary compatibility against previous versions.") + + def enableMimaSettings(failOnProblem: Boolean = true): Seq[Setting[_]] = + Def.settings( + checkMima := { if (isScalaJVM.value && !(checkMima / skip).value) mimaReportBinaryIssues.value else () }, + mimaFailOnProblem := failOnProblem, + mimaPreviousArtifacts := previousStableVersion.value.map(organization.value %% moduleName.value % _).toSet, + mimaBinaryIssueFilters := Seq() + ) + +} diff --git a/zio-sbt-ecosystem/src/main/scala/zio/sbt/ZioSbtEcosystemPlugin.scala b/zio-sbt-ecosystem/src/main/scala/zio/sbt/ZioSbtEcosystemPlugin.scala index 24a71670..faee0f36 100644 --- a/zio-sbt-ecosystem/src/main/scala/zio/sbt/ZioSbtEcosystemPlugin.scala +++ b/zio-sbt-ecosystem/src/main/scala/zio/sbt/ZioSbtEcosystemPlugin.scala @@ -28,15 +28,16 @@ import sbtbuildinfo.BuildInfoPlugin import scalafix.sbt.ScalafixPlugin import zio.sbt.ZioSbtShared.autoImport.{banners, usefulTasksAndSettings, welcomeMessage} +import com.typesafe.tools.mima.plugin.MimaPlugin object ZioSbtEcosystemPlugin extends AutoPlugin { override def trigger = allRequirements override def requires: Plugins = - super.requires && HeaderPlugin && ScalafixPlugin && ScalafmtPlugin && BuildInfoPlugin && ZioSbtCrossbuildPlugin + super.requires && HeaderPlugin && ScalafixPlugin && ScalafmtPlugin && BuildInfoPlugin && ZioSbtCrossbuildPlugin && MimaPlugin - object autoImport extends ScalaCompilerSettings { + object autoImport extends ScalaCompilerSettings with MimaSettings { def addCommand(commandString: List[String], name: String, description: String): Seq[Setting[_]] = { val cCommand = Commands.ComposableCommand(commandString, name, description)