@@ -3,6 +3,7 @@ import sbt.Def
3
3
import sbt .Reference .display
4
4
import com .softwaremill .SbtSoftwareMillCommon .commonSmlBuildSettings
5
5
import com .softwaremill .Publish .{ossPublishSettings , updateDocs }
6
+ import complete .DefaultParsers ._
6
7
7
8
val scala212 = " 2.12.16"
8
9
val scala213 = " 2.13.8"
@@ -14,10 +15,19 @@ val scalatestVersion = "3.2.12"
14
15
val specs2Version = " 4.16.1"
15
16
val smlTaggingVersion = " 2.3.3"
16
17
18
+ val scopesDescription = " Scala version can be: 2.12, 2.13, 3; platform: JVM, JS, Native"
19
+ val compileScoped =
20
+ inputKey[Unit ](
21
+ s " Compiles sources in the given scope. Usage: compileScoped [scala version] [platform]. $scopesDescription"
22
+ )
23
+ val testScoped =
24
+ inputKey[Unit ](s " Run tests in the given scope. Usage: testScoped [scala version] [platform]. $scopesDescription" )
25
+
17
26
lazy val commonSettings : Seq [Def .Setting [_]] = commonSmlBuildSettings ++ ossPublishSettings ++ Seq (
18
27
organization := " com.softwaremill.diffx" ,
19
28
scmInfo
:= Some (
ScmInfo (url(
" https://github.com/softwaremill/diffx" ),
" [email protected] :softwaremill/diffx.git" )),
20
29
ideSkipProject := (scalaVersion.value != scalaIdeaVersion) || thisProjectRef.value.project.contains(" JS" ),
30
+ mimaPreviousArtifacts := Set .empty, // we only use MiMa for `core` for now, using enableMimaSettings
21
31
updateDocs := Def .taskDyn {
22
32
val files1 = UpdateVersionInDocs (sLog.value, organization.value, version.value)
23
33
Def .task {
@@ -32,6 +42,16 @@ compileDocs := {
32
42
(docs.jvm(scala213) / mdoc).toTask(" --out target/diffx-docs" ).value
33
43
}
34
44
45
+ val versioningSchemeSettings = Seq (versionScheme := Some (" early-semver" ))
46
+
47
+ val enableMimaSettings = Seq (
48
+ mimaPreviousArtifacts := {
49
+ val previous = previousStableVersion.value
50
+ println(s " [info] Not a M or RC version, using previous version for MiMa check: $previous" )
51
+ previous.map(organization.value %% moduleName.value % _).toSet
52
+ }
53
+ )
54
+
35
55
val versionSpecificScalaSources = {
36
56
Compile / unmanagedSourceDirectories := {
37
57
val current = (Compile / unmanagedSourceDirectories).value
@@ -50,6 +70,7 @@ val versionSpecificScalaSources = {
50
70
51
71
lazy val core = (projectMatrix in file(" core" ))
52
72
.settings(commonSettings)
73
+ .settings(versioningSchemeSettings)
53
74
.settings(
54
75
name := " diffx-core" ,
55
76
libraryDependencies ++= {
@@ -74,7 +95,8 @@ lazy val core = (projectMatrix in file("core"))
74
95
versionSpecificScalaSources
75
96
)
76
97
.jvmPlatform(
77
- scalaVersions = List (scala212, scala213, scala3)
98
+ scalaVersions = List (scala212, scala213, scala3),
99
+ settings = enableMimaSettings
78
100
)
79
101
.jsPlatform(
80
102
scalaVersions = List (scala212, scala213, scala3),
@@ -289,6 +311,19 @@ val allAggregates =
289
311
def filterProject (p : String => Boolean ) =
290
312
ScopeFilter (inProjects(allAggregates.filter(pr => p(display(pr.project))): _* ))
291
313
314
+ def filterByVersionAndPlatform (scalaVersionFilter : String , platformFilter : String ) = filterProject { projectName =>
315
+ val byPlatform =
316
+ if (platformFilter == " JVM" ) ! projectName.contains(" JS" ) && ! projectName.contains(" Native" )
317
+ else projectName.contains(platformFilter)
318
+ val byVersion = scalaVersionFilter match {
319
+ case " 2.13" => ! projectName.contains(" 2_12" ) && ! projectName.contains(" 3" )
320
+ case " 2.12" => projectName.contains(" 2_12" )
321
+ case " 3" => projectName.contains(" 3" )
322
+ }
323
+
324
+ byPlatform && byVersion && ! projectName.contains(" finatra" )
325
+ }
326
+
292
327
lazy val rootProject = project
293
328
.in(file(" ." ))
294
329
.settings(commonSettings)
@@ -297,6 +332,14 @@ lazy val rootProject = project
297
332
name := " diffx" ,
298
333
scalaVersion := scalaIdeaVersion,
299
334
testJVM := (Test / test).all(filterProject(p => ! p.contains(" JS" ) && ! p.contains(" Native" ))).value,
300
- testJS := (Test / test).all(filterProject(_.contains(" JS" ))).value
335
+ testJS := (Test / test).all(filterProject(_.contains(" JS" ))).value,
336
+ compileScoped := Def .inputTaskDyn {
337
+ val args = spaceDelimited(" <arg>" ).parsed
338
+ Def .taskDyn((Compile / compile).all(filterByVersionAndPlatform(args.head, args(1 ))))
339
+ }.evaluated,
340
+ testScoped := Def .inputTaskDyn {
341
+ val args = spaceDelimited(" <arg>" ).parsed
342
+ Def .taskDyn((Test / test).all(filterByVersionAndPlatform(args.head, args(1 ))))
343
+ }.evaluated
301
344
)
302
345
.aggregate(allAggregates : _* )
0 commit comments