1- import mimabuild ._
1+ import mimabuild .*
2+
3+ import scala .util .Properties
24
35inThisBuild(Seq (
46 organization := " com.typesafe" ,
@@ -11,9 +13,18 @@ inThisBuild(Seq(
1113 ),
1214 scmInfo := Some (ScmInfo (url(" https://github.com/lightbend-labs/mima" ), " scm:git:git@github.com:lightbend-labs/mima.git" )),
1315 versionScheme := Some (" early-semver" ),
14- scalaVersion := scala212,
1516))
1617
18+ lazy val commonSettings : Seq [Setting [_]] = Seq (
19+ // in order to build `sbtplugin`, the `scalaVersion` of `core.jvm` has to match (2.12 or 3.8)
20+ scalaVersion := crossScalaVersions.value.headOption.getOrElse((LocalProject (" sbtplugin" ) / scalaVersion).value),
21+ publish / skip := crossScalaVersions.value.isEmpty,
22+ publishLocal / skip := false , // sbtplugin/scripted requires publishLocal
23+ scalacOptions ++= compilerOptions(scalaVersion.value),
24+ )
25+
26+ def java8or17 [T ](if8 : => T , if17 : => T ): T = if (Properties .isJavaAtLeast(" 17" )) if17 else if8
27+
1728def compilerOptions (scalaVersion : String ): Seq [String ] =
1829 Seq (
1930 " -feature" ,
@@ -36,23 +47,22 @@ def compilerOptions(scalaVersion: String): Seq[String] =
3647// Keep in sync with TestCli
3748val scala212 = " 2.12.21"
3849val scala213 = " 2.13.18"
39- val scala3 = " 3.3.7" // keep at LTS
50+ val scala3_3 = " 3.3.7" // keep at LTS
4051val scala3_8 = " 3.8.1" // keep at 3.8 for sbt 2 plugin
4152
42- val root = project.in(file(" ." )).settings(
53+ val root = project.in(file(" ." )).settings(commonSettings).settings(
4354 name := " mima" ,
4455 crossScalaVersions := Nil ,
4556 mimaFailOnNoPrevious := false ,
46- publish / skip := true ,
4757)
58+
4859aggregateProjects(core.jvm, core.native, cli.jvm, sbtplugin, functionalTests, integrationTests)
4960
5061val munit = Def .setting(" org.scalameta" %%% " munit" % " 1.2.2" )
5162
52- val core = crossProject(JVMPlatform , NativePlatform ).crossType(CrossType .Pure ).settings(
63+ val core = crossProject(JVMPlatform , NativePlatform ).crossType(CrossType .Pure ).settings(commonSettings).settings(
5364 name := " mima-core" ,
54- crossScalaVersions ++= Seq (scala213, scala3),
55- scalacOptions ++= compilerOptions(scalaVersion.value),
65+ crossScalaVersions := java8or17(Seq (scala212, scala213, scala3_3), Nil ),
5666 libraryDependencies += munit.value % Test ,
5767 MimaSettings .mimaSettings,
5868 apiMappings ++= {
@@ -69,28 +79,24 @@ val core = crossProject(JVMPlatform, NativePlatform).crossType(CrossType.Pure).s
6979
7080val cli = crossProject(JVMPlatform )
7181 .crossType(CrossType .Pure )
82+ .settings(commonSettings)
7283 .settings(
7384 name := " mima-cli" ,
74- crossScalaVersions ++= Seq (scala213, scala3),
75- scalacOptions ++= compilerOptions(scalaVersion.value),
85+ crossScalaVersions := java8or17(Seq (scala212, scala213, scala3_3), Nil ),
7686 libraryDependencies += munit.value % Test ,
77- MimaSettings .mimaSettings,
78- // cli has no previous release,
79- // but also we don't care about its binary compatibility as it's meant to be used standalone
80- mimaPreviousArtifacts := Set .empty
87+ mimaFailOnNoPrevious := false ,
8188 )
8289 .dependsOn(core)
8390
84- val sbtplugin = project.enablePlugins(SbtPlugin ).dependsOn(core.jvm).settings(
91+ val sbtplugin = project.enablePlugins(SbtPlugin ).dependsOn(core.jvm).settings(commonSettings).settings(
8592 name := " sbt-mima-plugin" ,
86- crossScalaVersions ++= Seq (scala3_8),
93+ crossScalaVersions := java8or17( Seq (scala212), Seq ( scala3_8) ),
8794 (pluginCrossBuild / sbtVersion) := {
8895 scalaBinaryVersion.value match {
8996 case " 2.12" => " 1.5.8"
9097 case _ => " 2.0.0-RC9"
9198 }
9299 },
93- scalacOptions ++= compilerOptions(scalaVersion.value),
94100 // drop the previous value to drop running Test/compile
95101 scriptedDependencies := Def .task(()).dependsOn(publishLocal, core.jvm / publishLocal).value,
96102 scriptedLaunchOpts += s " -Dplugin.version= ${version.value}" ,
@@ -104,26 +110,26 @@ val sbtplugin = project.enablePlugins(SbtPlugin).dependsOn(core.jvm).settings(
104110val testFunctional = taskKey[Unit ](" Run the functional test" )
105111val functionalTests = Project (" functional-tests" , file(" functional-tests" ))
106112 .dependsOn(core.jvm)
113+ .settings(commonSettings)
107114 .settings(
108- crossScalaVersions += scala213,
115+ crossScalaVersions := java8or17(Seq (scala212, scala213), Nil ),
116+ publish / skip := true ,
109117 libraryDependencies += " io.get-coursier" %% " coursier" % " 2.1.24" ,
110118 libraryDependencies += " org.scala-lang" % " scala-reflect" % scalaVersion.value,
111119 libraryDependencies += munit.value,
112- scalacOptions ++= compilerOptions(scalaVersion.value),
113120 testFunctional := (Test / test).value,
114121 Test / mainClass := Some (" com.typesafe.tools.mima.lib.UnitTests" ),
115122 mimaFailOnNoPrevious := false ,
116- publish / skip := true ,
117123 )
118124
119125val integrationTests = Project (" integration-tests" , file(" integration-tests" ))
120126 .dependsOn(functionalTests % " compile->compile" )
127+ .settings(commonSettings)
121128 .settings(
122- crossScalaVersions += scala213,
129+ crossScalaVersions := java8or17(Seq (scala212, scala213), Nil ),
130+ publish / skip := true ,
123131 libraryDependencies += munit.value,
124- scalacOptions ++= compilerOptions(scalaVersion.value),
125132 Test / unmanagedSourceDirectories := Seq ((functionalTests / baseDirectory).value / " src" / " it" / " scala" ),
126133 Test / testOptions += Tests .Argument (TestFrameworks .MUnit , " -b" ), // disable buffering => immediate output
127134 mimaFailOnNoPrevious := false ,
128- publish / skip := true ,
129135 )
0 commit comments