Skip to content

Commit

Permalink
Only native will use 3.3.3, while other stays as 3.1.3.
Browse files Browse the repository at this point in the history
  • Loading branch information
cheeseng committed Apr 20, 2024
1 parent cacb8bb commit 745651b
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 45 deletions.
97 changes: 57 additions & 40 deletions project/DottyBuild.scala
Expand Up @@ -19,11 +19,15 @@ trait DottyBuild { this: BuildCommons =>

// List of available night build at https://repo1.maven.org/maven2/ch/epfl/lamp/dotty-compiler_0.27/
// lazy val dottyVersion = dottyLatestNightlyBuild.get
lazy val dottyVersion = System.getProperty("scalatest.dottyVersion", "3.3.3")
lazy val dottyVersion = System.getProperty("scalatest.dottyVersion", "3.1.3")
lazy val dottySettings = List(
scalaVersion := dottyVersion,
scalacOptions ++= List("-language:implicitConversions", "-noindent", "-Xprint-suspension")
)
lazy val nativeDottySettings = List(
scalaVersion := "3.3.3",
scalacOptions ++= List("-language:implicitConversions", "-noindent", "-Xprint-suspension")
)

// https://github.com/sbt/sbt/issues/2205#issuecomment-144375501
private lazy val packageManagedSources =
Expand Down Expand Up @@ -150,7 +154,7 @@ trait DottyBuild { this: BuildCommons =>
lazy val scalacticDottyNative = project.in(file("dotty/scalactic.native"))
.enablePlugins(SbtOsgi)
.settings(sharedSettings: _*)
.settings(dottySettings: _*)
.settings(nativeDottySettings: _*)
.settings(scalacticDocSettings: _*)
.settings(
projectTitle := "Scalactic",
Expand Down Expand Up @@ -357,7 +361,7 @@ trait DottyBuild { this: BuildCommons =>
lazy val scalatestCoreDottyNative = project.in(file("dotty/core.native"))
.enablePlugins(SbtOsgi)
.settings(sharedSettings: _*)
.settings(dottySettings: _*)
.settings(nativeDottySettings: _*)
.settings(
projectTitle := "ScalaTest Core Dotty",
organization := "org.scalatest",
Expand Down Expand Up @@ -420,27 +424,29 @@ trait DottyBuild { this: BuildCommons =>

private implicit class DottyProjectEx(private val p: Project) {
/** common settings for all scalatest modules */
def scalatestModule(name: String, title: String): Project = p
.enablePlugins(SbtOsgi)
.settings(sharedSettings: _*)
.settings(dottySettings: _*)
.settings(
projectTitle := title,
organization := "org.scalatest",
moduleName := name,
packageManagedSources,
osgiSettings,
OsgiKeys.additionalHeaders := Map(
"Bundle-Name" -> title,
"Bundle-Description" -> "ScalaTest is an open-source test framework for the Javascript Platform designed to increase your productivity by letting you write fewer lines of test code that more clearly reveal your intent.",
"Bundle-DocURL" -> "http://www.scalatest.org/",
"Bundle-Vendor" -> "Artima, Inc."
),
def scalatestModule(name: String, title: String, isNative: Boolean): Project = {
val selectedDottySettings = if (isNative) nativeDottySettings else dottySettings
p.enablePlugins(SbtOsgi)
.settings(sharedSettings: _*)
.settings(selectedDottySettings: _*)
.settings(
projectTitle := title,
organization := "org.scalatest",
moduleName := name,
packageManagedSources,
osgiSettings,
OsgiKeys.additionalHeaders := Map(
"Bundle-Name" -> title,
"Bundle-Description" -> "ScalaTest is an open-source test framework for the Javascript Platform designed to increase your productivity by letting you write fewer lines of test code that more clearly reveal your intent.",
"Bundle-DocURL" -> "http://www.scalatest.org/",
"Bundle-Vendor" -> "Artima, Inc."
),
)
}

/** common settings for all scalatest sub modules (all modules, except the `scalatest` module) */
def scalatestSubModule(name: String, title: String, gen: GenModulesDotty.GenFn): Project =
scalatestModule(name, title).settings(
def scalatestSubModule(name: String, title: String, isNative: Boolean, gen: GenModulesDotty.GenFn): Project =
scalatestModule(name, title, isNative).settings(
sourceGenerators in Compile += Def.task {
gen((sourceManaged in Compile).value, version.value, scalaVersion.value)
}.taskValue,
Expand All @@ -452,21 +458,21 @@ trait DottyBuild { this: BuildCommons =>

/** common settings for all scalatest `style` modules such as `featurespec`, `funsuite`,.. */
def scalatestStyleModule(style: String, title: String): Project =
scalatestSubModule(s"scalatest-$style", title, GenModulesDotty(style))
scalatestSubModule(s"scalatest-$style", title, false, GenModulesDotty(style))
.settings(
OsgiKeys.exportPackage := Seq(s"org.scalatest.$style"),
).dependsOn(scalatestCoreDotty)

/** common settings for all scalatest js `style` modules such as `featurespec`, `funsuite`,.. */
def scalatestStyleModuleJS(style: String, title: String): Project =
scalatestSubModule(s"scalatest-$style", title, GenModulesDotty.applyJS(style))
scalatestSubModule(s"scalatest-$style", title, false, GenModulesDotty.applyJS(style))
.settings(
OsgiKeys.exportPackage := Seq(s"org.scalatest.$style"),
).dependsOn(scalatestCoreDottyJS).enablePlugins(ScalaJSPlugin)

/** common settings for all scalatest native `style` modules such as `featurespec`, `funsuite`,.. */
def scalatestStyleModuleNative(style: String, title: String): Project =
scalatestSubModule(s"scalatest-$style", title, GenModulesDotty.applyNative(style))
scalatestSubModule(s"scalatest-$style", title, true, GenModulesDotty.applyNative(style))
.settings(
OsgiKeys.exportPackage := Seq(s"org.scalatest.$style.*"),
).dependsOn(scalatestCoreDottyNative).enablePlugins(ScalaNativePlugin)
Expand Down Expand Up @@ -552,6 +558,7 @@ trait DottyBuild { this: BuildCommons =>
.scalatestSubModule(
"scalatest-diagrams",
"ScalaTest Diagrams Dotty JS",
false,
(targetDir, version, scalaVersion) =>
GenScalaTestDotty.genDiagramsScalaJS(targetDir / "org" / "scalatest", version, scalaVersion)
).settings(
Expand All @@ -565,6 +572,7 @@ trait DottyBuild { this: BuildCommons =>
.scalatestSubModule(
"scalatest-diagrams",
"ScalaTest Diagrams Dotty Native",
true,
(targetDir, version, scalaVersion) =>
GenScalaTestDotty.genDiagramsScalaNative(targetDir / "org" / "scalatest", version, scalaVersion)
).settings(
Expand All @@ -578,6 +586,7 @@ trait DottyBuild { this: BuildCommons =>
.scalatestSubModule(
"scalatest-matchers-core",
"ScalaTest Matchers Core Dotty",
false,
(targetDir, version, scalaVersion) => {
GenModulesDotty.genScalaTestMatchersCore(targetDir, version, scalaVersion) ++
GenFactoriesDotty.genMain(targetDir / "org" / "scalatest" / "matchers" / "dsl", version, scalaVersion)
Expand All @@ -593,6 +602,7 @@ trait DottyBuild { this: BuildCommons =>
.scalatestSubModule(
"scalatest-matchers-core",
"ScalaTest Matchers Core Dotty JS",
false,
(targetDir, version, scalaVersion) => {
GenModulesDotty.genScalaTestMatchersCoreJS(targetDir, version, scalaVersion) ++
GenScalaTestDotty.genMatchersCoreScalaJS(targetDir, version, scalaVersion) ++
Expand All @@ -609,6 +619,7 @@ trait DottyBuild { this: BuildCommons =>
.scalatestSubModule(
"scalatest-matchers-core",
"ScalaTest Matchers Core Dotty Native",
true,
(targetDir, version, scalaVersion) => {
GenModulesDotty.genScalaTestMatchersCoreNative(targetDir, version, scalaVersion) ++
GenScalaTestDotty.genMatchersCoreScalaNative(targetDir, version, scalaVersion) ++
Expand All @@ -625,6 +636,7 @@ trait DottyBuild { this: BuildCommons =>
.scalatestSubModule(
"scalatest-shouldmatchers",
"ScalaTest Should Matchers Dotty",
false,
GenModulesDotty.genScalaTestShouldMatchers
).settings(
OsgiKeys.exportPackage := Seq("org.scalatest.matchers.should"),
Expand All @@ -634,6 +646,7 @@ trait DottyBuild { this: BuildCommons =>
.scalatestSubModule(
"scalatest-shouldmatchers",
"ScalaTest Should Matchers Dotty JS",
false,
(targetDir, version, scalaVersion) => {
GenModulesDotty.genScalaTestShouldMatchersJS(targetDir, version, scalaVersion) ++
GenScalaTestDotty.genShouldMatchersScalaJS(targetDir, version, scalaVersion)
Expand All @@ -646,6 +659,7 @@ trait DottyBuild { this: BuildCommons =>
.scalatestSubModule(
"scalatest-shouldmatchers",
"ScalaTest Should Matchers Dotty Native",
true,
(targetDir, version, scalaVersion) => {
GenModulesDotty.genScalaTestShouldMatchersNative(targetDir, version, scalaVersion) ++
GenScalaTestDotty.genShouldMatchersScalaNative(targetDir, version, scalaVersion)
Expand All @@ -658,6 +672,7 @@ trait DottyBuild { this: BuildCommons =>
.scalatestSubModule(
"scalatest-mustmatchers",
"ScalaTest Must Matchers Dotty",
false,
(targetDir, version, scalaVersion) =>
GenMatchers.genMainForDotty(targetDir / "org" / "scalatest", version, scalaVersion)
).settings(
Expand All @@ -668,6 +683,7 @@ trait DottyBuild { this: BuildCommons =>
.scalatestSubModule(
"scalatest-mustmatchers",
"ScalaTest Must Matchers Dotty JS ",
false,
(targetDir, version, scalaVersion) =>
GenMatchers.genMainForDottyJS(targetDir / "org" / "scalatest", version, scalaVersion) ++
GenScalaTestDotty.genMustMatchersScalaJS(targetDir, version, scalaVersion)
Expand All @@ -679,6 +695,7 @@ trait DottyBuild { this: BuildCommons =>
.scalatestSubModule(
"scalatest-mustmatchers",
"ScalaTest Must Matchers Dotty Native ",
true,
(targetDir, version, scalaVersion) =>
GenMatchers.genMainForDottyNative(targetDir / "org" / "scalatest", version, scalaVersion) ++
GenScalaTestDotty.genMustMatchersScalaNative(targetDir, version, scalaVersion)
Expand Down Expand Up @@ -708,7 +725,7 @@ trait DottyBuild { this: BuildCommons =>
)

lazy val scalatestDotty = project.in(file("dotty/scalatest"))
.scalatestModule("scalatest", "ScalaTest Dotty")
.scalatestModule("scalatest", "ScalaTest Dotty", false)
.settings(
// Little trick to get rid of bnd error when publish.
sourceGenerators in Compile += Def.task {
Expand Down Expand Up @@ -747,7 +764,7 @@ trait DottyBuild { this: BuildCommons =>
)

lazy val scalatestDottyJS = project.in(file("dotty/scalatest.js"))
.scalatestModule("scalatest", "ScalaTest Dotty JS")
.scalatestModule("scalatest", "ScalaTest Dotty JS", false)
.settings(
// Little trick to get rid of bnd error when publish.
sourceGenerators in Compile += Def.task {
Expand Down Expand Up @@ -786,7 +803,7 @@ trait DottyBuild { this: BuildCommons =>
).enablePlugins(ScalaJSPlugin)

lazy val scalatestDottyNative = project.in(file("dotty/scalatest.native"))
.scalatestModule("scalatest", "ScalaTest Dotty Native")
.scalatestModule("scalatest", "ScalaTest Dotty Native", true)
.settings(
// Little trick to get rid of bnd error when publish.
sourceGenerators in Compile += Def.task {
Expand Down Expand Up @@ -1112,7 +1129,7 @@ trait DottyBuild { this: BuildCommons =>
lazy val scalatestAppDottyNative = project.in(file("dotty/scalatest-app.native"))
.enablePlugins(SbtOsgi)
.settings(sharedSettings)
.settings(dottySettings: _*)
.settings(nativeDottySettings: _*)
.settings(
projectTitle := "ScalaTest App",
name := "scalatest-app",
Expand Down Expand Up @@ -1282,10 +1299,10 @@ trait DottyBuild { this: BuildCommons =>

lazy val commonTestDottyNative = project.in(file("dotty/common-test.native"))
.settings(sharedSettings: _*)
.settings(dottySettings: _*)
.settings(nativeDottySettings: _*)
.settings(
projectTitle := "Common test classes used by scalactic and scalatest",
libraryDependencies ++= crossBuildTestLibraryDependencies.value,
libraryDependencies += "org.scala-lang.modules" %%% "scala-parser-combinators" % "2.4.0",
sourceGenerators in Compile += Def.task {
GenCommonTestDotty.genMainJS((sourceManaged in Compile).value / "scala", version.value, scalaVersion.value) ++
GenGen.genMain((sourceManaged in Compile).value / "scala" / "org" / "scalatest" / "prop", version.value, scalaVersion.value) ++
Expand Down Expand Up @@ -1339,7 +1356,7 @@ trait DottyBuild { this: BuildCommons =>

lazy val scalacticTestDottyNative = project.in(file("dotty/scalactic-test.native"))
.settings(sharedSettings: _*)
.settings(dottySettings: _*)
.settings(nativeDottySettings: _*)
.settings(sharedTestSettingsNative: _*)
.settings(
projectTitle := "Scalactic Test Native",
Expand Down Expand Up @@ -1440,7 +1457,7 @@ trait DottyBuild { this: BuildCommons =>

lazy val scalatestTestDottyNative = project.in(file("dotty/scalatest-test.native"))
.settings(sharedSettings: _*)
.settings(dottySettings: _*)
.settings(nativeDottySettings: _*)
.settings(sharedTestSettingsNative: _*)
.settings(
projectTitle := "ScalaTest Test",
Expand Down Expand Up @@ -1485,7 +1502,7 @@ trait DottyBuild { this: BuildCommons =>

lazy val scalatestDiagramsTestDottyNative = project.in(file("dotty/diagrams-test.native"))
.settings(sharedSettings: _*)
.settings(dottySettings: _*)
.settings(nativeDottySettings: _*)
.settings(sharedTestSettingsNative)
.settings(
projectTitle := "ScalaTest Diagrams Test",
Expand Down Expand Up @@ -1518,7 +1535,7 @@ trait DottyBuild { this: BuildCommons =>

lazy val scalatestFeatureSpecTestDottyNative = project.in(file("dotty/featurespec-test.native"))
.settings(sharedSettings: _*)
.settings(dottySettings: _*)
.settings(nativeDottySettings: _*)
.settings(sharedTestSettingsNative)
.settings(
projectTitle := "ScalaTest FeatureSpec Test",
Expand Down Expand Up @@ -1551,7 +1568,7 @@ trait DottyBuild { this: BuildCommons =>

lazy val scalatestFlatSpecTestDottyNative = project.in(file("dotty/flatspec-test.native"))
.settings(sharedSettings: _*)
.settings(dottySettings: _*)
.settings(nativeDottySettings: _*)
.settings(sharedTestSettingsNative)
.settings(
projectTitle := "ScalaTest FlatSpec Test",
Expand Down Expand Up @@ -1584,7 +1601,7 @@ trait DottyBuild { this: BuildCommons =>

lazy val scalatestFreeSpecTestDottyNative = project.in(file("dotty/freespec-test.native"))
.settings(sharedSettings: _*)
.settings(dottySettings: _*)
.settings(nativeDottySettings: _*)
.settings(sharedTestSettingsNative)
.settings(
projectTitle := "ScalaTest FreeSpec Test",
Expand Down Expand Up @@ -1617,7 +1634,7 @@ trait DottyBuild { this: BuildCommons =>

lazy val scalatestFunSpecTestDottyNative = project.in(file("dotty/funspec-test.native"))
.settings(sharedSettings: _*)
.settings(dottySettings: _*)
.settings(nativeDottySettings: _*)
.settings(sharedTestSettingsNative)
.settings(
projectTitle := "ScalaTest FunSpec Test",
Expand Down Expand Up @@ -1650,7 +1667,7 @@ trait DottyBuild { this: BuildCommons =>

lazy val scalatestFunSuiteTestDottyNative = project.in(file("dotty/funsuite-test.native"))
.settings(sharedSettings: _*)
.settings(dottySettings: _*)
.settings(nativeDottySettings: _*)
.settings(sharedTestSettingsNative)
.settings(
projectTitle := "ScalaTest FunSuite Test",
Expand Down Expand Up @@ -1683,7 +1700,7 @@ trait DottyBuild { this: BuildCommons =>

lazy val scalatestPropSpecTestDottyNative = project.in(file("dotty/propspec-test.native"))
.settings(sharedSettings: _*)
.settings(dottySettings: _*)
.settings(nativeDottySettings: _*)
.settings(sharedTestSettingsNative)
.settings(
projectTitle := "ScalaTest PropSpec Test",
Expand Down Expand Up @@ -1716,7 +1733,7 @@ trait DottyBuild { this: BuildCommons =>

lazy val scalatestWordSpecTestDottyNative = project.in(file("dotty/wordspec-test.native"))
.settings(sharedSettings: _*)
.settings(dottySettings: _*)
.settings(nativeDottySettings: _*)
.settings(sharedTestSettingsNative)
.settings(
projectTitle := "ScalaTest WordSpec Test",
Expand Down
5 changes: 0 additions & 5 deletions project/scalatest.scala
Expand Up @@ -156,11 +156,6 @@ object ScalatestBuild extends BuildCommons with DottyBuild with NativeBuild with
case Some((2, scalaMajor)) if scalaMajor == 10 =>
Seq.empty

case Some((3, _)) => // for scala 3.x
Seq(
"org.scala-lang.modules" %%% "scala-parser-combinators" % "2.4.0"
)

case _ => // for scala 2.11, 2.12, 2.13
Seq(
"org.scala-lang.modules" %%% "scala-parser-combinators" % "2.1.1"
Expand Down

0 comments on commit 745651b

Please sign in to comment.