Skip to content

Commit

Permalink
add enableMimaSettings
Browse files Browse the repository at this point in the history
  • Loading branch information
ThijsBroersen committed Nov 16, 2024
1 parent 6278bc7 commit b44ab58
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
1 change: 1 addition & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
40 changes: 40 additions & 0 deletions zio-sbt-ecosystem/src/main/scala/zio/sbt/MimaSettings.scala
Original file line number Diff line number Diff line change
@@ -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()
)

}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b44ab58

Please sign in to comment.