@@ -30,13 +30,13 @@ import scala.util.Properties.isJavaAtLeast
3030
3131import org .portablescala .sbtplatformdeps .PlatformDepsPlugin .autoImport ._
3232
33- object MyScalaJSPlugin extends AutoPlugin {
33+ abstract class DottyJSPlugin ( settings : Seq [ Setting [_]]) extends AutoPlugin {
3434 import Build ._
3535
3636 override def requires : Plugins = ScalaJSPlugin
3737
3838 override def projectSettings : Seq [Setting [_]] = Def .settings(
39- commonBootstrappedSettings ,
39+ settings ,
4040
4141 /* #11709 Remove the dependency on scala3-library that ScalaJSPlugin adds.
4242 * Instead, in this build, we use `.dependsOn` relationships to depend on
@@ -61,6 +61,8 @@ object MyScalaJSPlugin extends AutoPlugin {
6161 excludeFromIDE := true
6262 )
6363}
64+ object BootstrappedDottyJSPlugin extends DottyJSPlugin (Build .commonBootstrappedSettings)
65+ object NonBootstrappedDottyJSPlugin extends DottyJSPlugin (Build .commonNonBootstrappedSettings)
6466
6567object Build {
6668 val referenceVersion = " 3.0.0-RC2-bin-20210318-e60ef35-NIGHTLY"
@@ -350,8 +352,6 @@ object Build {
350352 },
351353 // sbt-dotty defines `scalaInstance in doc` so we need to override it manually
352354 doc / scalaInstance := scalaInstance.value,
353-
354- disableDocSetting,
355355 )
356356
357357 lazy val commonBenchmarkSettings = Seq (
@@ -689,6 +689,16 @@ object Build {
689689 case Bootstrapped => `scala3-library-bootstrapped`
690690 }
691691
692+ lazy val `scala3-library-js` : Project = project.in(file(" library-js" )).
693+ asDottyLibrary(NonBootstrapped ).
694+ enablePlugins(NonBootstrappedDottyJSPlugin ).
695+ settings(
696+ libraryDependencies +=
697+ (" org.scala-js" %% " scalajs-library" % scalaJSVersion).withDottyCompat(scalaVersion.value),
698+ unmanagedSourceDirectories in Compile :=
699+ (unmanagedSourceDirectories in (`scala3-library`, Compile )).value
700+ )
701+
692702 /** The dotty standard library compiled with the Scala.js back-end, to produce
693703 * the corresponding .sjsir files.
694704 *
@@ -700,7 +710,7 @@ object Build {
700710 */
701711 lazy val `scala3-library-bootstrappedJS` : Project = project.in(file(" library-js" )).
702712 asDottyLibrary(Bootstrapped ).
703- enablePlugins(MyScalaJSPlugin ).
713+ enablePlugins(BootstrappedDottyJSPlugin ).
704714 settings(
705715 libraryDependencies +=
706716 (" org.scala-js" %% " scalajs-library" % scalaJSVersion).withDottyCompat(scalaVersion.value),
@@ -981,7 +991,7 @@ object Build {
981991 * useful, as that would not provide the linker and JS runners.
982992 */
983993 lazy val sjsSandbox = project.in(file(" sandbox/scalajs" )).
984- enablePlugins(MyScalaJSPlugin ).
994+ enablePlugins(BootstrappedDottyJSPlugin ).
985995 dependsOn(`scala3-library-bootstrappedJS`).
986996 settings(
987997 // Required to run Scala.js tests.
@@ -998,7 +1008,7 @@ object Build {
9981008 * It will grow in the future, as more stuff is confirmed to be supported.
9991009 */
10001010 lazy val sjsJUnitTests = project.in(file(" tests/sjs-junit" )).
1001- enablePlugins(MyScalaJSPlugin ).
1011+ enablePlugins(BootstrappedDottyJSPlugin ).
10021012 dependsOn(`scala3-library-bootstrappedJS`).
10031013 settings(
10041014 scalacOptions --= Seq (" -Xfatal-warnings" , " -deprecation" ),
@@ -1056,7 +1066,7 @@ object Build {
10561066 (Compile / sourceManaged).value,
10571067 " org.scalajs.testsuite.utils.BuildInfo" ,
10581068 " scalaVersion" -> scalaVersion.value,
1059- " hasSourceMaps" -> false , // MyScalaJSPlugin .wantSourceMaps.value,
1069+ " hasSourceMaps" -> false , // BootstrappedDottyJSPlugin .wantSourceMaps.value,
10601070 " isNoModule" -> (moduleKind == ModuleKind .NoModule ),
10611071 " isESModule" -> (moduleKind == ModuleKind .ESModule ),
10621072 " isCommonJSModule" -> (moduleKind == ModuleKind .CommonJSModule ),
@@ -1180,9 +1190,21 @@ object Build {
11801190 case Bootstrapped => scaladoc
11811191 }
11821192
1183- lazy val `scaladoc-testcases` = project.in(file(" scaladoc-testcases" )).asScaladocTestcases
1193+ lazy val `scaladoc-testcases` = project.in(file(" scaladoc-testcases" )).asScaladocTestcases(Bootstrapped )
1194+ lazy val `scaladoc-testcases-nonBootstrapped` = project.in(file(" scaladoc-testcases" )).asScaladocTestcases(NonBootstrapped )
1195+
1196+ def scalaDocTestcases (implicit mode : Mode ): Project = mode match {
1197+ case NonBootstrapped => `scaladoc-testcases-nonBootstrapped`
1198+ case Bootstrapped => `scaladoc-testcases`
1199+ }
1200+
1201+ lazy val `scaladoc-js` = project.in(file(" scaladoc-js" )).asScaladocJs(Bootstrapped )
1202+ lazy val `scaladoc-js-nonBootstrapped` = project.in(file(" scaladoc-js" )).asScaladocJs(NonBootstrapped )
11841203
1185- lazy val `scaladoc-js` = project.in(file(" scaladoc-js" )).asScaladocJs
1204+ def scalaDocJs (implicit mode : Mode ): Project = mode match {
1205+ case NonBootstrapped => `scaladoc-js-nonBootstrapped`
1206+ case Bootstrapped => `scaladoc-js`
1207+ }
11861208
11871209 // sbt plugin to use Dotty in your own build, see
11881210 // https://github.com/lampepfl/scala3-example-project for usage.
@@ -1517,42 +1539,53 @@ object Build {
15171539 settings(commonBenchmarkSettings).
15181540 enablePlugins(JmhPlugin )
15191541
1520- def scaladocBasic (mode : Mode ): Project = {
1542+ def scaladocBasic (implicit mode : Mode ): Project = {
15211543 val flexmarkVersion = " 0.42.12"
15221544
1523- val base = if (mode == Bootstrapped )
1524- project.settings(commonBootstrappedSettings).
1525- dependsOn(`scala3-compiler-bootstrapped`).
1526- dependsOn(`scala3-tasty-inspector`)
1527- else
1528- project.settings(commonNonBootstrappedSettings).
1529- dependsOn(`scala3-compiler`).
1530- dependsOn(`scala3-tasty-inspector-nonbootstrapped`)
1531-
1532- base.settings(
1533- libraryDependencies ++= Seq (
1534- " com.vladsch.flexmark" % " flexmark" % flexmarkVersion,
1535- " com.vladsch.flexmark" % " flexmark-html-parser" % flexmarkVersion,
1536- " com.vladsch.flexmark" % " flexmark-ext-anchorlink" % flexmarkVersion,
1537- " com.vladsch.flexmark" % " flexmark-ext-autolink" % flexmarkVersion,
1538- " com.vladsch.flexmark" % " flexmark-ext-emoji" % flexmarkVersion,
1539- " com.vladsch.flexmark" % " flexmark-ext-gfm-strikethrough" % flexmarkVersion,
1540- " com.vladsch.flexmark" % " flexmark-ext-gfm-tables" % flexmarkVersion,
1541- " com.vladsch.flexmark" % " flexmark-ext-gfm-tasklist" % flexmarkVersion,
1542- " com.vladsch.flexmark" % " flexmark-ext-wikilink" % flexmarkVersion,
1543- " com.vladsch.flexmark" % " flexmark-ext-yaml-front-matter" % flexmarkVersion,
1544- " nl.big-o" % " liqp" % " 0.6.7" ,
1545- " org.jsoup" % " jsoup" % " 1.13.1" , // Needed to process .html files for static site
1546- Dependencies .`jackson-dataformat-yaml`,
1547-
1548- " com.novocode" % " junit-interface" % " 0.11" % " test" ,
1549- ),
1550- Compile / mainClass := Some (" dotty.tools.scaladoc.Main" ),
1551- Compile / buildInfoKeys := Seq [BuildInfoKey ](version),
1552- Compile / buildInfoPackage := " dotty.tools.scaladoc" ,
1553- BuildInfoPlugin .buildInfoScopedSettings(Compile ),
1554- BuildInfoPlugin .buildInfoDefaultSettings,
1555- )
1545+ val base = if (mode == Bootstrapped )
1546+ project.settings(commonBootstrappedSettings)
1547+ .dependsOn(`scala3-compiler-bootstrapped`)
1548+ .dependsOn(`scala3-tasty-inspector`)
1549+ else
1550+ project.settings(commonNonBootstrappedSettings)
1551+ .dependsOn(`scala3-compiler`)
1552+ .dependsOn(`scala3-tasty-inspector-nonbootstrapped`)
1553+
1554+ base.settings(
1555+ Compile / resourceGenerators += Def .task {
1556+ val jsDestinationFile = (Compile / resourceManaged).value / " dotty_res" / " scripts" / " searchbar.js"
1557+ sbt.IO .copyFile((scalaDocJs / Compile / fullOptJS).value.data, jsDestinationFile)
1558+ Seq (jsDestinationFile)
1559+ }.taskValue,
1560+ Compile / resourceGenerators += Def .task {
1561+ val cssDesitnationFile = (Compile / resourceManaged).value / " dotty_res" / " styles" / " scaladoc-searchbar.css"
1562+ val cssSourceFile = (scalaDocJs / Compile / resourceDirectory).value / " scaladoc-searchbar.css"
1563+ sbt.IO .copyFile(cssSourceFile, cssDesitnationFile)
1564+ Seq (cssDesitnationFile)
1565+ }.taskValue,
1566+ libraryDependencies ++= Seq (
1567+ " com.vladsch.flexmark" % " flexmark" % flexmarkVersion,
1568+ " com.vladsch.flexmark" % " flexmark-html-parser" % flexmarkVersion,
1569+ " com.vladsch.flexmark" % " flexmark-ext-anchorlink" % flexmarkVersion,
1570+ " com.vladsch.flexmark" % " flexmark-ext-autolink" % flexmarkVersion,
1571+ " com.vladsch.flexmark" % " flexmark-ext-emoji" % flexmarkVersion,
1572+ " com.vladsch.flexmark" % " flexmark-ext-gfm-strikethrough" % flexmarkVersion,
1573+ " com.vladsch.flexmark" % " flexmark-ext-gfm-tables" % flexmarkVersion,
1574+ " com.vladsch.flexmark" % " flexmark-ext-gfm-tasklist" % flexmarkVersion,
1575+ " com.vladsch.flexmark" % " flexmark-ext-wikilink" % flexmarkVersion,
1576+ " com.vladsch.flexmark" % " flexmark-ext-yaml-front-matter" % flexmarkVersion,
1577+ " nl.big-o" % " liqp" % " 0.6.7" ,
1578+ " org.jsoup" % " jsoup" % " 1.13.1" , // Needed to process .html files for static site
1579+ Dependencies .`jackson-dataformat-yaml`,
1580+
1581+ " com.novocode" % " junit-interface" % " 0.11" % " test" ,
1582+ ),
1583+ Compile / mainClass := Some (" dotty.tools.scaladoc.Main" ),
1584+ Compile / buildInfoKeys := Seq [BuildInfoKey ](version),
1585+ Compile / buildInfoPackage := " dotty.tools.scaladoc" ,
1586+ BuildInfoPlugin .buildInfoScopedSettings(Compile ),
1587+ BuildInfoPlugin .buildInfoDefaultSettings,
1588+ )
15561589 }
15571590
15581591 def asScaladoc : Project = {
@@ -1668,36 +1701,29 @@ object Build {
16681701 (Test / Build .testcasesSourceRoot),
16691702 Build .testDocumentationRoot,
16701703 ),
1671- Compile / resourceGenerators += Def .task {
1672- val jsDestinationFile = (Compile / resourceManaged).value / " dotty_res" / " scripts" / " searchbar.js"
1673- sbt.IO .copyFile((`scaladoc-js` / Compile / fullOptJS).value.data, jsDestinationFile)
1674- Seq (jsDestinationFile)
1675- }.taskValue,
1676- Compile / resourceGenerators += Def .task {
1677- val cssDesitnationFile = (Compile / resourceManaged).value / " dotty_res" / " styles" / " scaladoc-searchbar.css"
1678- val cssSourceFile = (`scaladoc-js` / Compile / resourceDirectory).value / " scaladoc-searchbar.css"
1679- sbt.IO .copyFile(cssSourceFile, cssDesitnationFile)
1680- Seq (cssDesitnationFile)
1681- }.taskValue,
16821704 testDocumentationRoot := (baseDirectory.value / " test-documentations" ).getAbsolutePath,
16831705 Test / buildInfoPackage := " dotty.tools.scaladoc.test" ,
16841706 BuildInfoPlugin .buildInfoScopedSettings(Test ),
16851707 )
16861708 }
16871709
1688- def asScaladocTestcases : Project =
1689- project.dependsOn(`scala3-compiler-bootstrapped`).settings(commonBootstrappedSettings)
1690-
1691- def asScaladocJs : Project =
1692- project.
1693- enablePlugins(MyScalaJSPlugin ).
1694- dependsOn(`scala3-library-bootstrappedJS`).
1695- settings(
1696- Test / fork := false ,
1697- scalaJSUseMainModuleInitializer := true ,
1698- libraryDependencies += (" org.scala-js" %%% " scalajs-dom" % " 1.1.0" ).withDottyCompat(scalaVersion.value)
1699- )
1700-
1710+ def asScaladocTestcases (implicit mode : Mode ): Project =
1711+ if (mode == Bootstrapped )
1712+ project.dependsOn(`scala3-compiler-bootstrapped`).settings(commonBootstrappedSettings)
1713+ else
1714+ project.dependsOn(`scala3-compiler`).settings(commonNonBootstrappedSettings)
1715+
1716+ def asScaladocJs (implicit mode : Mode ): Project = {
1717+ val pr = if (mode == Bootstrapped )
1718+ project.enablePlugins(BootstrappedDottyJSPlugin ).dependsOn(`scala3-library-bootstrappedJS`)
1719+ else
1720+ project.enablePlugins(NonBootstrappedDottyJSPlugin ).dependsOn(`scala3-library-js`)
1721+ pr.settings(
1722+ Test / fork := false ,
1723+ scalaJSUseMainModuleInitializer := true ,
1724+ libraryDependencies += (" org.scala-js" %%% " scalajs-dom" % " 1.1.0" ).withDottyCompat(scalaVersion.value)
1725+ )
1726+ }
17011727
17021728 def asDist (implicit mode : Mode ): Project = project.
17031729 enablePlugins(PackPlugin ).
0 commit comments