@@ -30,13 +30,13 @@ import scala.util.Properties.isJavaAtLeast
30
30
31
31
import org .portablescala .sbtplatformdeps .PlatformDepsPlugin .autoImport ._
32
32
33
- object MyScalaJSPlugin extends AutoPlugin {
33
+ abstract class DottyJSPlugin ( settings : Seq [ Setting [_]]) extends AutoPlugin {
34
34
import Build ._
35
35
36
36
override def requires : Plugins = ScalaJSPlugin
37
37
38
38
override def projectSettings : Seq [Setting [_]] = Def .settings(
39
- commonBootstrappedSettings ,
39
+ settings ,
40
40
41
41
// Replace the JVM JUnit dependency by the Scala.js one
42
42
libraryDependencies ~= {
@@ -53,6 +53,8 @@ object MyScalaJSPlugin extends AutoPlugin {
53
53
excludeFromIDE := true
54
54
)
55
55
}
56
+ object BootstrappedDottyJSPlugin extends DottyJSPlugin (Build .commonBootstrappedSettings)
57
+ object NonBootstrappedDottyJSPlugin extends DottyJSPlugin (Build .commonNonBootstrappedSettings)
56
58
57
59
object Build {
58
60
val referenceVersion = " 3.0.0-RC1"
@@ -342,9 +344,7 @@ object Build {
342
344
)
343
345
},
344
346
// sbt-dotty defines `scalaInstance in doc` so we need to override it manually
345
- scalaInstance in doc := scalaInstance.value,
346
-
347
- disableDocSetting,
347
+ scalaInstance in doc := scalaInstance.value
348
348
)
349
349
350
350
lazy val commonBenchmarkSettings = Seq (
@@ -691,6 +691,16 @@ object Build {
691
691
case Bootstrapped => `scala3-library-bootstrapped`
692
692
}
693
693
694
+ lazy val `scala3-library-js` : Project = project.in(file(" library-js" )).
695
+ asDottyLibrary(NonBootstrapped ).
696
+ enablePlugins(NonBootstrappedDottyJSPlugin ).
697
+ settings(
698
+ libraryDependencies +=
699
+ (" org.scala-js" %% " scalajs-library" % scalaJSVersion).withDottyCompat(scalaVersion.value),
700
+ unmanagedSourceDirectories in Compile :=
701
+ (unmanagedSourceDirectories in (`scala3-library`, Compile )).value
702
+ )
703
+
694
704
/** The dotty standard library compiled with the Scala.js back-end, to produce
695
705
* the corresponding .sjsir files.
696
706
*
@@ -702,7 +712,7 @@ object Build {
702
712
*/
703
713
lazy val `scala3-library-bootstrappedJS` : Project = project.in(file(" library-js" )).
704
714
asDottyLibrary(Bootstrapped ).
705
- enablePlugins(MyScalaJSPlugin ).
715
+ enablePlugins(BootstrappedDottyJSPlugin ).
706
716
settings(
707
717
libraryDependencies +=
708
718
(" org.scala-js" %% " scalajs-library" % scalaJSVersion).withDottyCompat(scalaVersion.value),
@@ -982,7 +992,7 @@ object Build {
982
992
* useful, as that would not provide the linker and JS runners.
983
993
*/
984
994
lazy val sjsSandbox = project.in(file(" sandbox/scalajs" )).
985
- enablePlugins(MyScalaJSPlugin ).
995
+ enablePlugins(BootstrappedDottyJSPlugin ).
986
996
dependsOn(`scala3-library-bootstrappedJS`).
987
997
settings(
988
998
// Required to run Scala.js tests.
@@ -999,7 +1009,7 @@ object Build {
999
1009
* It will grow in the future, as more stuff is confirmed to be supported.
1000
1010
*/
1001
1011
lazy val sjsJUnitTests = project.in(file(" tests/sjs-junit" )).
1002
- enablePlugins(MyScalaJSPlugin ).
1012
+ enablePlugins(BootstrappedDottyJSPlugin ).
1003
1013
dependsOn(`scala3-library-bootstrappedJS`).
1004
1014
settings(
1005
1015
scalacOptions --= Seq (" -Xfatal-warnings" , " -deprecation" ),
@@ -1057,7 +1067,7 @@ object Build {
1057
1067
(sourceManaged in Compile ).value,
1058
1068
" org.scalajs.testsuite.utils.BuildInfo" ,
1059
1069
" scalaVersion" -> scalaVersion.value,
1060
- " hasSourceMaps" -> false , // MyScalaJSPlugin .wantSourceMaps.value,
1070
+ " hasSourceMaps" -> false , // BootstrappedDottyJSPlugin .wantSourceMaps.value,
1061
1071
" isNoModule" -> (moduleKind == ModuleKind .NoModule ),
1062
1072
" isESModule" -> (moduleKind == ModuleKind .ESModule ),
1063
1073
" isCommonJSModule" -> (moduleKind == ModuleKind .CommonJSModule ),
@@ -1177,9 +1187,21 @@ object Build {
1177
1187
case Bootstrapped => scaladoc
1178
1188
}
1179
1189
1180
- lazy val `scaladoc-testcases` = project.in(file(" scaladoc-testcases" )).asScaladocTestcases
1190
+ lazy val `scaladoc-testcases` = project.in(file(" scaladoc-testcases" )).asScaladocTestcases(Bootstrapped )
1191
+ lazy val `scaladoc-testcases-nonBootstrapped` = project.in(file(" scaladoc-testcases" )).asScaladocTestcases(NonBootstrapped )
1181
1192
1182
- lazy val `scaladoc-js` = project.in(file(" scaladoc-js" )).asScaladocJs
1193
+ def scalaDocTestcases (implicit mode : Mode ): Project = mode match {
1194
+ case NonBootstrapped => `scaladoc-testcases-nonBootstrapped`
1195
+ case Bootstrapped => `scaladoc-testcases`
1196
+ }
1197
+
1198
+ lazy val `scaladoc-js` = project.in(file(" scaladoc-js" )).asScaladocJs(Bootstrapped )
1199
+ lazy val `scaladoc-js-nonBootstrapped` = project.in(file(" scaladoc-js" )).asScaladocJs(NonBootstrapped )
1200
+
1201
+ def scalaDocJs (implicit mode : Mode ): Project = mode match {
1202
+ case NonBootstrapped => `scaladoc-js-nonBootstrapped`
1203
+ case Bootstrapped => `scaladoc-js`
1204
+ }
1183
1205
1184
1206
// sbt plugin to use Dotty in your own build, see
1185
1207
// https://github.com/lampepfl/scala3-example-project for usage.
@@ -1514,42 +1536,53 @@ object Build {
1514
1536
settings(commonBenchmarkSettings).
1515
1537
enablePlugins(JmhPlugin )
1516
1538
1517
- def scaladocBasic (mode : Mode ): Project = {
1539
+ def scaladocBasic (implicit mode : Mode ): Project = {
1518
1540
val flexmarkVersion = " 0.42.12"
1519
1541
1520
- val base = if (mode == Bootstrapped )
1521
- project.settings(commonBootstrappedSettings).
1522
- dependsOn(`scala3-compiler-bootstrapped`).
1523
- dependsOn(`scala3-tasty-inspector`)
1524
- else
1525
- project.settings(commonNonBootstrappedSettings).
1526
- dependsOn(`scala3-compiler`).
1527
- dependsOn(`scala3-tasty-inspector-nonbootstrapped`)
1528
-
1529
- base.settings(
1530
- libraryDependencies ++= Seq (
1531
- " com.vladsch.flexmark" % " flexmark" % flexmarkVersion,
1532
- " com.vladsch.flexmark" % " flexmark-html-parser" % flexmarkVersion,
1533
- " com.vladsch.flexmark" % " flexmark-ext-anchorlink" % flexmarkVersion,
1534
- " com.vladsch.flexmark" % " flexmark-ext-autolink" % flexmarkVersion,
1535
- " com.vladsch.flexmark" % " flexmark-ext-emoji" % flexmarkVersion,
1536
- " com.vladsch.flexmark" % " flexmark-ext-gfm-strikethrough" % flexmarkVersion,
1537
- " com.vladsch.flexmark" % " flexmark-ext-gfm-tables" % flexmarkVersion,
1538
- " com.vladsch.flexmark" % " flexmark-ext-gfm-tasklist" % flexmarkVersion,
1539
- " com.vladsch.flexmark" % " flexmark-ext-wikilink" % flexmarkVersion,
1540
- " com.vladsch.flexmark" % " flexmark-ext-yaml-front-matter" % flexmarkVersion,
1541
- " nl.big-o" % " liqp" % " 0.6.7" ,
1542
- " org.jsoup" % " jsoup" % " 1.13.1" , // Needed to process .html files for static site
1543
- Dependencies .`jackson-dataformat-yaml`,
1544
-
1545
- " com.novocode" % " junit-interface" % " 0.11" % " test" ,
1546
- ),
1547
- Compile / mainClass := Some (" dotty.tools.scaladoc.Main" ),
1548
- Compile / buildInfoKeys := Seq [BuildInfoKey ](version),
1549
- Compile / buildInfoPackage := " dotty.tools.scaladoc" ,
1550
- BuildInfoPlugin .buildInfoScopedSettings(Compile ),
1551
- BuildInfoPlugin .buildInfoDefaultSettings,
1552
- )
1542
+ val base = if (mode == Bootstrapped )
1543
+ project.settings(commonBootstrappedSettings)
1544
+ .dependsOn(`scala3-compiler-bootstrapped`)
1545
+ .dependsOn(`scala3-tasty-inspector`)
1546
+ else
1547
+ project.settings(commonNonBootstrappedSettings)
1548
+ .dependsOn(`scala3-compiler`)
1549
+ .dependsOn(`scala3-tasty-inspector-nonbootstrapped`)
1550
+
1551
+ base.settings(
1552
+ Compile / resourceGenerators += Def .task {
1553
+ val jsDestinationFile = (Compile / resourceManaged).value / " dotty_res" / " scripts" / " searchbar.js"
1554
+ sbt.IO .copyFile((fullOptJS in Compile in scalaDocJs).value.data, jsDestinationFile)
1555
+ Seq (jsDestinationFile)
1556
+ }.taskValue,
1557
+ Compile / resourceGenerators += Def .task {
1558
+ val cssDesitnationFile = (Compile / resourceManaged).value / " dotty_res" / " styles" / " scaladoc-searchbar.css"
1559
+ val cssSourceFile = (resourceDirectory in Compile in scalaDocJs).value / " scaladoc-searchbar.css"
1560
+ sbt.IO .copyFile(cssSourceFile, cssDesitnationFile)
1561
+ Seq (cssDesitnationFile)
1562
+ }.taskValue,
1563
+ libraryDependencies ++= Seq (
1564
+ " com.vladsch.flexmark" % " flexmark" % flexmarkVersion,
1565
+ " com.vladsch.flexmark" % " flexmark-html-parser" % flexmarkVersion,
1566
+ " com.vladsch.flexmark" % " flexmark-ext-anchorlink" % flexmarkVersion,
1567
+ " com.vladsch.flexmark" % " flexmark-ext-autolink" % flexmarkVersion,
1568
+ " com.vladsch.flexmark" % " flexmark-ext-emoji" % flexmarkVersion,
1569
+ " com.vladsch.flexmark" % " flexmark-ext-gfm-strikethrough" % flexmarkVersion,
1570
+ " com.vladsch.flexmark" % " flexmark-ext-gfm-tables" % flexmarkVersion,
1571
+ " com.vladsch.flexmark" % " flexmark-ext-gfm-tasklist" % flexmarkVersion,
1572
+ " com.vladsch.flexmark" % " flexmark-ext-wikilink" % flexmarkVersion,
1573
+ " com.vladsch.flexmark" % " flexmark-ext-yaml-front-matter" % flexmarkVersion,
1574
+ " nl.big-o" % " liqp" % " 0.6.7" ,
1575
+ " org.jsoup" % " jsoup" % " 1.13.1" , // Needed to process .html files for static site
1576
+ Dependencies .`jackson-dataformat-yaml`,
1577
+
1578
+ " com.novocode" % " junit-interface" % " 0.11" % " test" ,
1579
+ ),
1580
+ Compile / mainClass := Some (" dotty.tools.scaladoc.Main" ),
1581
+ Compile / buildInfoKeys := Seq [BuildInfoKey ](version),
1582
+ Compile / buildInfoPackage := " dotty.tools.scaladoc" ,
1583
+ BuildInfoPlugin .buildInfoScopedSettings(Compile ),
1584
+ BuildInfoPlugin .buildInfoDefaultSettings,
1585
+ )
1553
1586
}
1554
1587
1555
1588
def asScaladoc : Project = {
@@ -1658,36 +1691,29 @@ object Build {
1658
1691
Build .testcasesSourceRoot.in(Test ),
1659
1692
Build .testDocumentationRoot,
1660
1693
),
1661
- Compile / resourceGenerators += Def .task {
1662
- val jsDestinationFile = (Compile / resourceManaged).value / " dotty_res" / " scripts" / " searchbar.js"
1663
- sbt.IO .copyFile((fullOptJS in Compile in `scaladoc-js`).value.data, jsDestinationFile)
1664
- Seq (jsDestinationFile)
1665
- }.taskValue,
1666
- Compile / resourceGenerators += Def .task {
1667
- val cssDesitnationFile = (Compile / resourceManaged).value / " dotty_res" / " styles" / " scaladoc-searchbar.css"
1668
- val cssSourceFile = (resourceDirectory in Compile in `scaladoc-js`).value / " scaladoc-searchbar.css"
1669
- sbt.IO .copyFile(cssSourceFile, cssDesitnationFile)
1670
- Seq (cssDesitnationFile)
1671
- }.taskValue,
1672
1694
testDocumentationRoot := (baseDirectory.value / " test-documentations" ).getAbsolutePath,
1673
1695
buildInfoPackage in Test := " dotty.tools.scaladoc.test" ,
1674
1696
BuildInfoPlugin .buildInfoScopedSettings(Test ),
1675
1697
)
1676
1698
}
1677
1699
1678
- def asScaladocTestcases : Project =
1679
- project.dependsOn(`scala3-compiler-bootstrapped`).settings(commonBootstrappedSettings)
1680
-
1681
- def asScaladocJs : Project =
1682
- project.
1683
- enablePlugins(MyScalaJSPlugin ).
1684
- dependsOn(`scala3-library-bootstrappedJS`).
1685
- settings(
1686
- fork in Test := false ,
1687
- scalaJSUseMainModuleInitializer := true ,
1688
- libraryDependencies += (" org.scala-js" %%% " scalajs-dom" % " 1.1.0" ).withDottyCompat(scalaVersion.value)
1689
- )
1690
-
1700
+ def asScaladocTestcases (implicit mode : Mode ): Project =
1701
+ if (mode == Bootstrapped )
1702
+ project.dependsOn(`scala3-compiler-bootstrapped`).settings(commonBootstrappedSettings)
1703
+ else
1704
+ project.dependsOn(`scala3-compiler`).settings(commonNonBootstrappedSettings)
1705
+
1706
+ def asScaladocJs (implicit mode : Mode ): Project = {
1707
+ val pr = if (mode == Bootstrapped )
1708
+ project.enablePlugins(BootstrappedDottyJSPlugin ).dependsOn(`scala3-library-bootstrappedJS`)
1709
+ else
1710
+ project.enablePlugins(NonBootstrappedDottyJSPlugin ).dependsOn(`scala3-library-js`)
1711
+ pr.settings(
1712
+ fork in Test := false ,
1713
+ scalaJSUseMainModuleInitializer := true ,
1714
+ libraryDependencies += (" org.scala-js" %%% " scalajs-dom" % " 1.1.0" ).withDottyCompat(scalaVersion.value)
1715
+ )
1716
+ }
1691
1717
1692
1718
def asDist (implicit mode : Mode ): Project = project.
1693
1719
enablePlugins(PackPlugin ).
0 commit comments