@@ -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
@@ -72,6 +74,29 @@ object Build {
72
74
val publishedDottyVersion = referenceVersion
73
75
val sbtDottyVersion = " 0.5.5"
74
76
77
+ /** Version against which we check binary compatibility.
78
+ *
79
+ * This must be the latest published release in the same versioning line.
80
+ * For example, if the next version is going to be 3.1.4, then this must be
81
+ * set to 3.1.3. If it is going to be 3.1.0, it must be set to the latest
82
+ * 3.0.x release.
83
+ */
84
+ val previousDottyVersion = " 3.0.0-RC3"
85
+ val previousDottyBinaryVersion = " 3.0.0-RC3"
86
+
87
+ object CompatMode {
88
+ final val BinaryCompatible = 0
89
+ final val SourceAndBinaryCompatible = 1
90
+ }
91
+
92
+ val compatMode = {
93
+ val VersionRE = """ ^\d+\.(\d+).(\d+).*""" .r
94
+ baseVersion match {
95
+ case VersionRE (_, " 0" ) => CompatMode .BinaryCompatible
96
+ case _ => CompatMode .SourceAndBinaryCompatible
97
+ }
98
+ }
99
+
75
100
/** scala-library version required to compile Dotty.
76
101
*
77
102
* Both the non-bootstrapped and bootstrapped version should match, unless
@@ -392,6 +417,22 @@ object Build {
392
417
javaOptions += " -DBENCH_CLASS_PATH=" + Attributed .data((`scala3-library-bootstrapped` / Compile / fullClasspath).value).mkString(" " , File .pathSeparator, " " )
393
418
)
394
419
420
+ lazy val commonMiMaSettings = Def .settings(
421
+ mimaPreviousArtifacts += {
422
+ val thisProjectID = projectID.value
423
+ val crossedName = thisProjectID.crossVersion match {
424
+ case cv : Disabled => thisProjectID.name
425
+ case cv : Binary => s " ${thisProjectID.name}_ ${cv.prefix}$previousDottyBinaryVersion${cv.suffix}"
426
+ }
427
+ (thisProjectID.organization % crossedName % previousDottyVersion)
428
+ },
429
+
430
+ mimaCheckDirection := (compatMode match {
431
+ case CompatMode .BinaryCompatible => " backward"
432
+ case CompatMode .SourceAndBinaryCompatible => " both"
433
+ }),
434
+ )
435
+
395
436
/** Projects -------------------------------------------------------------- */
396
437
397
438
val dottyCompilerBootstrappedRef = LocalProject (" scala3-compiler-bootstrapped" )
@@ -411,7 +452,8 @@ object Build {
411
452
lazy val `scala3-bootstrapped` = project.asDottyRoot(Bootstrapped )
412
453
413
454
lazy val `scala3-interfaces` = project.in(file(" interfaces" )).
414
- settings(commonJavaSettings)
455
+ settings(commonJavaSettings).
456
+ settings(commonMiMaSettings)
415
457
416
458
/** Find an artifact with the given `name` in `classpath` */
417
459
def findArtifact (classpath : Def .Classpath , name : String ): File = classpath
@@ -1636,15 +1678,17 @@ object Build {
1636
1678
).
1637
1679
settings(dottyLibrarySettings)
1638
1680
if (mode == Bootstrapped ) {
1639
- base.settings(Seq (
1681
+ base.settings(
1640
1682
(Compile / doc) := {
1641
1683
// Workaround for
1642
1684
// [error] |object IArray cannot have the same name as object IArray in package scala
1643
1685
// -- cannot define object member with the same name as a object member in self reference _.
1644
1686
val doWork = (Compile / doc).result.value
1645
1687
(Compile / doc/ target).value
1646
- }
1647
- ))
1688
+ },
1689
+ commonMiMaSettings,
1690
+ mimaBinaryIssueFilters ++= MiMaFilters .Library ,
1691
+ )
1648
1692
} else base
1649
1693
}
1650
1694
0 commit comments