@@ -15,6 +15,8 @@ import xerial.sbt.pack.PackPlugin
15
15
import xerial .sbt .pack .PackPlugin .autoImport ._
16
16
import xerial .sbt .Sonatype .autoImport ._
17
17
18
+ import com .typesafe .tools .mima .plugin .MimaPlugin .autoImport ._
19
+
18
20
import dotty .tools .sbtplugin .DottyIDEPlugin .{ installCodeExtension , prepareCommand , runProcess }
19
21
import dotty .tools .sbtplugin .DottyIDEPlugin .autoImport ._
20
22
@@ -74,6 +76,29 @@ object Build {
74
76
val publishedDottyVersion = referenceVersion
75
77
val sbtDottyVersion = " 0.5.5"
76
78
79
+ /** Version against which we check binary compatibility.
80
+ *
81
+ * This must be the latest published release in the same versioning line.
82
+ * For example, if the next version is going to be 3.1.4, then this must be
83
+ * set to 3.1.3. If it is going to be 3.1.0, it must be set to the latest
84
+ * 3.0.x release.
85
+ */
86
+ val previousDottyVersion = " 3.0.0-RC3"
87
+ val previousDottyBinaryVersion = " 3.0.0-RC3"
88
+
89
+ object CompatMode {
90
+ final val BinaryCompatible = 0
91
+ final val SourceAndBinaryCompatible = 1
92
+ }
93
+
94
+ val compatMode = {
95
+ val VersionRE = """ ^\d+\.(\d+).(\d+).*""" .r
96
+ baseVersion match {
97
+ case VersionRE (_, " 0" ) => CompatMode .BinaryCompatible
98
+ case _ => CompatMode .SourceAndBinaryCompatible
99
+ }
100
+ }
101
+
77
102
/** scala-library version required to compile Dotty.
78
103
*
79
104
* Both the non-bootstrapped and bootstrapped version should match, unless
@@ -381,6 +406,22 @@ object Build {
381
406
javaOptions += " -DBENCH_CLASS_PATH=" + Attributed .data((`scala3-library-bootstrapped` / Compile / fullClasspath).value).mkString(" " , File .pathSeparator, " " )
382
407
)
383
408
409
+ lazy val commonMiMaSettings = Def .settings(
410
+ mimaPreviousArtifacts += {
411
+ val thisProjectID = projectID.value
412
+ val crossedName = thisProjectID.crossVersion match {
413
+ case cv : Disabled => thisProjectID.name
414
+ case cv : Binary => s " ${thisProjectID.name}_ ${cv.prefix}$previousDottyBinaryVersion${cv.suffix}"
415
+ }
416
+ (thisProjectID.organization % crossedName % previousDottyVersion)
417
+ },
418
+
419
+ mimaCheckDirection := (compatMode match {
420
+ case CompatMode .BinaryCompatible => " backward"
421
+ case CompatMode .SourceAndBinaryCompatible => " both"
422
+ }),
423
+ )
424
+
384
425
/** Projects -------------------------------------------------------------- */
385
426
386
427
val dottyCompilerBootstrappedRef = LocalProject (" scala3-compiler-bootstrapped" )
@@ -400,7 +441,8 @@ object Build {
400
441
lazy val `scala3-bootstrapped` = project.asDottyRoot(Bootstrapped )
401
442
402
443
lazy val `scala3-interfaces` = project.in(file(" interfaces" )).
403
- settings(commonJavaSettings)
444
+ settings(commonJavaSettings).
445
+ settings(commonMiMaSettings)
404
446
405
447
/** Find an artifact with the given `name` in `classpath` */
406
448
def findArtifact (classpath : Def .Classpath , name : String ): File = classpath
@@ -1532,15 +1574,17 @@ object Build {
1532
1574
).
1533
1575
settings(dottyLibrarySettings)
1534
1576
if (mode == Bootstrapped ) {
1535
- base.settings(Seq (
1577
+ base.settings(
1536
1578
(Compile / doc) := {
1537
1579
// Workaround for
1538
1580
// [error] |object IArray cannot have the same name as object IArray in package scala
1539
1581
// -- cannot define object member with the same name as a object member in self reference _.
1540
1582
val doWork = (Compile / doc).result.value
1541
1583
(Compile / doc/ target).value
1542
- }
1543
- ))
1584
+ },
1585
+ commonMiMaSettings,
1586
+ mimaBinaryIssueFilters ++= MiMaFilters .Library ,
1587
+ )
1544
1588
} else base
1545
1589
}
1546
1590
0 commit comments