I have sbt cross compile platforms with many modules (Android,Scalajs,Native,JVM and shared) I wanted to control the test for each module through build.sbt file by writing a flags to each test eg: I wanted to test the Android module and Jvm only so I set the flags to true and others to false:
//Testing flags
val androidQuickTest = true
val jvmQuickTest = true
val scalaJsQuickTest = false
val nativeQuickTest = false
val sharedQuickTest = false
then I should add some control and checks to those flags and call the test command from sbt shell.
my build.sbt
file:
name := "CrossCompilePlatforms"
version := "0.1"
import sbtcrossproject.CrossPlugin.autoImport.{crossProject, CrossType}
val sharedSettings = Seq(scalaVersion := "2.11.12",
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.5" % "test"
)
val commonAndroidSettings = Seq(
scalaVersion := "2.11.8",
sbtVersion := "0.13.13",
scalacOptions += "-target:jvm-1.7",
javacOptions ++= Seq("-source", "1.7", "-target", "1.7"),
exportJars := true
)
val commonNativeSettings = Seq(
scalaVersion := "2.11.12",
nativeLinkStubs := true,
libraryDependencies += "org.scalatest" % "scalatest_native0.3_2.11" % "3.2.0-SNAP10"
)
lazy val myProject =
crossProject(JSPlatform, JVMPlatform)
.crossType(CrossType.Full)
.settings(sharedSettings)
.settings(libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.5" % "test")
.jsSettings(libraryDependencies += "org.querki" %%% "jquery-facade" % "1.2")
.jvmSettings()
lazy val myProjectJS = myProject.js.dependsOn(myProjectShared)
lazy val myProjectVM = myProject.jvm.dependsOn(myProjectShared)
lazy val myProjectNativeWin10 = project.in(file("./myProject/nativeWin10"))
.settings(sharedSettings)
.dependsOn(myProjectShared)
lazy val myProjectNativeUbuntu18 = project.in(file("./myProject/nativeUbuntu18"))
.enablePlugins(ScalaNativePlugin)
.settings(commonNativeSettings)
lazy val myProjectShared = project.in(file("./myProject/shared"))
.settings(sharedSettings)
lazy val myProjectAndroid = project.in(file("./myProject/android"))
.settings(commonAndroidSettings: _*)
.settings(
target := baseDirectory.value / ".android" / "target"
)
.dependsOn(myProjectShared)
The 2 things I know are:
Using Filters:
From https://stackoverflow.com/a/25853923/2750966
Using Tagging:
From ScalaTest Documentation