@@ -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,6 +15,14 @@ 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" )),
@@ -272,6 +281,19 @@ val allAggregates =
272
281
def filterProject (p : String => Boolean ) =
273
282
ScopeFilter (inProjects(allAggregates.filter(pr => p(display(pr.project))): _* ))
274
283
284
+ def filterByVersionAndPlatform (scalaVersionFilter : String , platformFilter : String ) = filterProject { projectName =>
285
+ val byPlatform =
286
+ if (platformFilter == " JVM" ) ! projectName.contains(" JS" ) && ! projectName.contains(" Native" )
287
+ else projectName.contains(platformFilter)
288
+ val byVersion = scalaVersionFilter match {
289
+ case " 2.13" => ! projectName.contains(" 2_12" ) && ! projectName.contains(" 3" )
290
+ case " 2.12" => projectName.contains(" 2_12" )
291
+ case " 3" => projectName.contains(" 3" )
292
+ }
293
+
294
+ byPlatform && byVersion && ! projectName.contains(" finatra" )
295
+ }
296
+
275
297
lazy val rootProject = project
276
298
.in(file(" ." ))
277
299
.settings(commonSettings)
@@ -280,6 +302,14 @@ lazy val rootProject = project
280
302
name := " diffx" ,
281
303
scalaVersion := scalaIdeaVersion,
282
304
testJVM := (Test / test).all(filterProject(p => ! p.contains(" JS" ) && ! p.contains(" Native" ))).value,
283
- testJS := (Test / test).all(filterProject(_.contains(" JS" ))).value
305
+ testJS := (Test / test).all(filterProject(_.contains(" JS" ))).value,
306
+ compileScoped := Def .inputTaskDyn {
307
+ val args = spaceDelimited(" <arg>" ).parsed
308
+ Def .taskDyn((Compile / compile).all(filterByVersionAndPlatform(args.head, args(1 ))))
309
+ }.evaluated,
310
+ testScoped := Def .inputTaskDyn {
311
+ val args = spaceDelimited(" <arg>" ).parsed
312
+ Def .taskDyn((Test / test).all(filterByVersionAndPlatform(args.head, args(1 ))))
313
+ }.evaluated
284
314
)
285
315
.aggregate(allAggregates : _* )
0 commit comments