diff --git a/build.sbt b/build.sbt index b2ec4a0b..2b55e4f8 100644 --- a/build.sbt +++ b/build.sbt @@ -16,6 +16,7 @@ inThisBuild( developers := List( Developer("khajavi", "Milad Khajavi", "khajavi@gmail.com", url("https://github.com/khajavi")) ), + checkMima / skip := true, ciEnabledBranches := Seq("main") ) ) diff --git a/project/plugins.sbt b/project/plugins.sbt index 21480e70..082bfe5a 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,5 +1,5 @@ // Build Server Plugins -addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "2.0.3") +addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "2.0.5") // Linting Plugins addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2") @@ -8,7 +8,7 @@ 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") +addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.13.1") addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.9.0") // Docs Plugins diff --git a/zio-sbt-ci/src/main/scala/zio/sbt/ZioSbtCiPlugin.scala b/zio-sbt-ci/src/main/scala/zio/sbt/ZioSbtCiPlugin.scala index fc3d0fc1..6aba56f7 100644 --- a/zio-sbt-ci/src/main/scala/zio/sbt/ZioSbtCiPlugin.scala +++ b/zio-sbt-ci/src/main/scala/zio/sbt/ZioSbtCiPlugin.scala @@ -88,7 +88,6 @@ object ZioSbtCiPlugin extends AutoPlugin { val ciBackgroundJobs: SettingKey[Seq[String]] = settingKey[Seq[String]]("Background jobs") val ciBuildJobs: SettingKey[Seq[Job]] = settingKey[Seq[Job]]("CI Build Jobs") val ciLintJobs: SettingKey[Seq[Job]] = settingKey[Seq[Job]]("CI Lint Jobs") - val ciCheckMima: SettingKey[Boolean] = settingKey[Boolean]("Enable Lint Job: Check binary compatibility") val ciTestJobs: SettingKey[Seq[Job]] = settingKey[Seq[Job]]("CI Test Jobs") val ciUpdateReadmeJobs: SettingKey[Seq[Job]] = settingKey[Seq[Job]]("CI Update Readme Jobs") val ciReleaseJobs: SettingKey[Seq[Job]] = settingKey[Seq[Job]]("CI Release Jobs") @@ -153,8 +152,7 @@ object ZioSbtCiPlugin extends AutoPlugin { ) ++ checkGithubWorkflow.flatMap( _.flatten ) ++ - Seq(Lint.value) ++ - (if (ciCheckMima.value) Seq(CheckMima.value) else Seq.empty[Step.SingleStep]) + Seq(Lint.value) ) ) } @@ -688,7 +686,6 @@ object ZioSbtCiPlugin extends AutoPlugin { ciDefaultJavaVersion := zio.sbt.JavaVersion.`17`, ciBuildJobs := buildJobs.value, ciLintJobs := lintJobs.value, - ciCheckMima := false, ciTestJobs := testJobs.value, ciUpdateReadmeJobs := updateReadmeJobs.value, ciReleaseJobs := releaseJobs.value, @@ -788,17 +785,6 @@ object ZioSbtCiPlugin extends AutoPlugin { ) } - lazy val CheckMima: Def.Initialize[Step.SingleStep] = Def.setting { - val backgroundJobs = ciBackgroundJobs.value - val prefixJobs = makePrefixJobs(backgroundJobs) - val isSingleBuild = IsSingleBuild.value - - Step.SingleStep( - name = "Check binary compatibility", - run = Some(prefixJobs + "sbt " + (if (isSingleBuild) "checkMima" else "+checkMima")) - ) - } - lazy val Release: Def.Initialize[SingleStep] = Def.setting { val backgroundJobs = ciBackgroundJobs.value diff --git a/zio-sbt-ecosystem/build.sbt b/zio-sbt-ecosystem/build.sbt index 969d1f84..8a7b0624 100644 --- a/zio-sbt-ecosystem/build.sbt +++ b/zio-sbt-ecosystem/build.sbt @@ -7,7 +7,7 @@ addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.13.0") addSbtPlugin("com.github.cb372" % "sbt-explicit-dependencies" % "0.3.1") // Versioning and Release Plugins -addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.12.0") +addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.13.1") addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.9.0") // Docs Plugins diff --git a/zio-sbt-ecosystem/src/main/scala/zio/sbt/Commands.scala b/zio-sbt-ecosystem/src/main/scala/zio/sbt/Commands.scala index f34c3e2a..29c7bc43 100644 --- a/zio-sbt-ecosystem/src/main/scala/zio/sbt/Commands.scala +++ b/zio-sbt-ecosystem/src/main/scala/zio/sbt/Commands.scala @@ -88,6 +88,9 @@ object Commands { val fmt: ComposableCommand = (quietOn >> "scalafmtSbt" >> "+scalafmt" >> "+Test / scalafmt") ?? ("fmt", "Formats source files using scalafmt.") + val checkMima: ComposableCommand = + (quietOn >> "+checkMima") ?? ("checkMima", "Checks binary compatibility against previous versions.") + // TODO: have the correct license headers val lint: ComposableCommand = { quietOn >> @@ -96,6 +99,7 @@ object Commands { "+scalafmtCheckAll" >> // "+headerCheckAll" >> fixLint >> + checkMima >> "disableStrictCompile" } ?? ( "lint", @@ -125,6 +129,7 @@ object Commands { lint.toItem, fmt.toItem, fix.toItem, + checkMima.toItem, prepare.toItem, // buildAll.toItem, prepare.toItem, diff --git a/zio-sbt-ecosystem/src/main/scala/zio/sbt/MimaSettings.scala b/zio-sbt-ecosystem/src/main/scala/zio/sbt/MimaSettings.scala index 68643b6e..c6dcc314 100644 --- a/zio-sbt-ecosystem/src/main/scala/zio/sbt/MimaSettings.scala +++ b/zio-sbt-ecosystem/src/main/scala/zio/sbt/MimaSettings.scala @@ -15,7 +15,6 @@ */ package zio.sbt - import com.typesafe.tools.mima.plugin.MimaKeys._ import sbt.Keys._ import sbt._ @@ -26,15 +25,23 @@ import zio.sbt.BuildAssertions.Keys.isScalaJVM trait MimaSettings { lazy val checkMima: TaskKey[Unit] = taskKey[Unit]("Checks binary compatibility against previous versions.") +} + +object MimaSettings extends MimaSettings { - def enableMimaSettings(failOnProblem: Boolean = true): Seq[Setting[_]] = + def projectSettings: Seq[Setting[_]] = Def.settings( - checkMima := { if (isScalaJVM.value && !(checkMima / skip).value) mimaReportBinaryIssues.value else () }, - mimaFailOnProblem := failOnProblem, - mimaPreviousArtifacts := previousStableVersion.value + checkMima := { + Def.taskIf { + if (isScalaJVM.value && !((checkMima / skip).value || (publish / skip).value)) mimaReportBinaryIssues.value + else () + }.value + }, + mimaFailOnProblem := false, + // mimaPreviousArtifacts := Set.empty, + mimaPreviousArtifacts := (ThisBuild / previousStableVersion).value .map(organization.value %% moduleName.value % _) - .fold(Set.empty[ModuleID])(Set(_)), - mimaBinaryIssueFilters := Seq() + .fold(Set.empty[ModuleID])(Set(_)) ) } 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 d1e69f27..6bbe6a0e 100644 --- a/zio-sbt-ecosystem/src/main/scala/zio/sbt/ZioSbtEcosystemPlugin.scala +++ b/zio-sbt-ecosystem/src/main/scala/zio/sbt/ZioSbtEcosystemPlugin.scala @@ -25,7 +25,7 @@ import org.scalafmt.sbt.ScalafmtPlugin import sbt.Keys._ import sbt.nio.Keys.{ReloadOnSourceChanges, onChangedBuildSource} import sbt.{Def, _} -import sbtbuildinfo.BuildInfoPlugin +import sbtdynver.DynVerPlugin import scalafix.sbt.ScalafixPlugin import zio.sbt.ZioSbtShared.autoImport.{banners, usefulTasksAndSettings, welcomeMessage} @@ -35,7 +35,7 @@ object ZioSbtEcosystemPlugin extends AutoPlugin { override def trigger = allRequirements override def requires: Plugins = - super.requires && HeaderPlugin && ScalafixPlugin && ScalafmtPlugin && BuildInfoPlugin && ZioSbtCrossbuildPlugin && MimaPlugin + super.requires && HeaderPlugin && ScalafixPlugin && ScalafmtPlugin && MimaPlugin && DynVerPlugin && ZioSbtCrossbuildPlugin object autoImport extends ScalaCompilerSettings with MimaSettings { @@ -75,7 +75,7 @@ object ZioSbtEcosystemPlugin extends AutoPlugin { onLoadMessage := { if (SharedTasks.isRoot.value) welcomeMessage.init.value else "" } - ) + ) ++ MimaSettings.projectSettings override def buildSettings: Seq[Def.Setting[_]] = super.buildSettings ++ Seq( zioVersion := zioVersion.?.value.getOrElse(Versions.zioVersion) diff --git a/zio-sbt-project/src/main/scala/zio/sbt/ScalaPlatform.scala b/zio-sbt-project/src/main/scala/zio/sbt/ScalaPlatform.scala index c3213f5d..8ccc9e2c 100644 --- a/zio-sbt-project/src/main/scala/zio/sbt/ScalaPlatform.scala +++ b/zio-sbt-project/src/main/scala/zio/sbt/ScalaPlatform.scala @@ -47,8 +47,6 @@ object ScalaPlatforms { .toSet } - def buildSettings: Seq[Setting[_]] = Seq.empty - def globalSettings: Seq[Setting[_]] = Seq( allScalaPlatformsSetting ) diff --git a/zio-sbt-project/src/main/scala/zio/sbt/ZioSbtCrossbuildPlugin.scala b/zio-sbt-project/src/main/scala/zio/sbt/ZioSbtCrossbuildPlugin.scala index baad533b..9d1935ca 100644 --- a/zio-sbt-project/src/main/scala/zio/sbt/ZioSbtCrossbuildPlugin.scala +++ b/zio-sbt-project/src/main/scala/zio/sbt/ZioSbtCrossbuildPlugin.scala @@ -58,7 +58,6 @@ object ZioSbtCrossbuildPlugin extends AutoPlugin { override def buildSettings: Seq[Def.Setting[_]] = super.buildSettings ++ ScalaVersions.buildSettings ++ - ScalaPlatforms.buildSettings ++ JavaVersions.buildSettings override def globalSettings: Seq[Def.Setting[_]] =