@@ -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
@@ -397,6 +422,22 @@ object Build {
397
422
javaOptions += " -DBENCH_CLASS_PATH=" + Attributed .data((`scala3-library-bootstrapped` / Compile / fullClasspath).value).mkString(" " , File .pathSeparator, " " )
398
423
)
399
424
425
+ lazy val commonMiMaSettings = Def .settings(
426
+ mimaPreviousArtifacts += {
427
+ val thisProjectID = projectID.value
428
+ val crossedName = thisProjectID.crossVersion match {
429
+ case cv : Disabled => thisProjectID.name
430
+ case cv : Binary => s " ${thisProjectID.name}_ ${cv.prefix}$previousDottyBinaryVersion${cv.suffix}"
431
+ }
432
+ (thisProjectID.organization % crossedName % previousDottyVersion)
433
+ },
434
+
435
+ mimaCheckDirection := (compatMode match {
436
+ case CompatMode .BinaryCompatible => " backward"
437
+ case CompatMode .SourceAndBinaryCompatible => " both"
438
+ }),
439
+ )
440
+
400
441
/** Projects -------------------------------------------------------------- */
401
442
402
443
val dottyCompilerBootstrappedRef = LocalProject (" scala3-compiler-bootstrapped" )
@@ -416,7 +457,8 @@ object Build {
416
457
lazy val `scala3-bootstrapped` = project.asDottyRoot(Bootstrapped )
417
458
418
459
lazy val `scala3-interfaces` = project.in(file(" interfaces" )).
419
- settings(commonJavaSettings)
460
+ settings(commonJavaSettings).
461
+ settings(commonMiMaSettings)
420
462
421
463
/** Find an artifact with the given `name` in `classpath` */
422
464
def findArtifact (classpath : Def .Classpath , name : String ): File = classpath
@@ -1641,15 +1683,17 @@ object Build {
1641
1683
).
1642
1684
settings(dottyLibrarySettings)
1643
1685
if (mode == Bootstrapped ) {
1644
- base.settings(Seq (
1686
+ base.settings(
1645
1687
(Compile / doc) := {
1646
1688
// Workaround for
1647
1689
// [error] |object IArray cannot have the same name as object IArray in package scala
1648
1690
// -- cannot define object member with the same name as a object member in self reference _.
1649
1691
val doWork = (Compile / doc).result.value
1650
1692
(Compile / doc/ target).value
1651
- }
1652
- ))
1693
+ },
1694
+ commonMiMaSettings,
1695
+ mimaBinaryIssueFilters ++= MiMaFilters .Library ,
1696
+ )
1653
1697
} else base
1654
1698
}
1655
1699
0 commit comments