我有带有许多模块(Android、Scalajs、Native、JVM 和共享)的 sbt 交叉编译平台我想通过 build.sbt 文件通过向每个测试写入标志来控制每个模块的测试,例如:我想测试 Android 模块和 Jvm,所以我将标志设置为 true,将其他标志设置为 false:
//Testing flags
val androidQuickTest = true
val jvmQuickTest = true
val scalaJsQuickTest = false
val nativeQuickTest = false
val sharedQuickTest = false
然后我应该对这些标志添加一些控制和检查,并从 sbt shell 调用测试命令。
我的 build.sbt
文件:
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)