@@ -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"
@@ -341,9 +343,7 @@ object Build {
341
343
)
342
344
},
343
345
// sbt-dotty defines `scalaInstance in doc` so we need to override it manually
344
- scalaInstance in doc := scalaInstance.value,
345
-
346
- disableDocSetting,
346
+ scalaInstance in doc := scalaInstance.value
347
347
)
348
348
349
349
lazy val commonBenchmarkSettings = Seq (
@@ -688,6 +688,16 @@ object Build {
688
688
case Bootstrapped => `scala3-library-bootstrapped`
689
689
}
690
690
691
+ lazy val `scala3-library-js` : Project = project.in(file(" library-js" )).
692
+ asDottyLibrary(NonBootstrapped ).
693
+ enablePlugins(NonBootstrappedDottyJSPlugin ).
694
+ settings(
695
+ libraryDependencies +=
696
+ (" org.scala-js" %% " scalajs-library" % scalaJSVersion).withDottyCompat(scalaVersion.value),
697
+ unmanagedSourceDirectories in Compile :=
698
+ (unmanagedSourceDirectories in (`scala3-library`, Compile )).value
699
+ )
700
+
691
701
/** The dotty standard library compiled with the Scala.js back-end, to produce
692
702
* the corresponding .sjsir files.
693
703
*
@@ -699,7 +709,7 @@ object Build {
699
709
*/
700
710
lazy val `scala3-library-bootstrappedJS` : Project = project.in(file(" library-js" )).
701
711
asDottyLibrary(Bootstrapped ).
702
- enablePlugins(MyScalaJSPlugin ).
712
+ enablePlugins(BootstrappedDottyJSPlugin ).
703
713
settings(
704
714
libraryDependencies +=
705
715
(" org.scala-js" %% " scalajs-library" % scalaJSVersion).withDottyCompat(scalaVersion.value),
@@ -979,7 +989,7 @@ object Build {
979
989
* useful, as that would not provide the linker and JS runners.
980
990
*/
981
991
lazy val sjsSandbox = project.in(file(" sandbox/scalajs" )).
982
- enablePlugins(MyScalaJSPlugin ).
992
+ enablePlugins(BootstrappedDottyJSPlugin ).
983
993
dependsOn(`scala3-library-bootstrappedJS`).
984
994
settings(
985
995
// Required to run Scala.js tests.
@@ -996,7 +1006,7 @@ object Build {
996
1006
* It will grow in the future, as more stuff is confirmed to be supported.
997
1007
*/
998
1008
lazy val sjsJUnitTests = project.in(file(" tests/sjs-junit" )).
999
- enablePlugins(MyScalaJSPlugin ).
1009
+ enablePlugins(BootstrappedDottyJSPlugin ).
1000
1010
dependsOn(`scala3-library-bootstrappedJS`).
1001
1011
settings(
1002
1012
scalacOptions --= Seq (" -Xfatal-warnings" , " -deprecation" ),
@@ -1054,7 +1064,7 @@ object Build {
1054
1064
(sourceManaged in Compile ).value,
1055
1065
" org.scalajs.testsuite.utils.BuildInfo" ,
1056
1066
" scalaVersion" -> scalaVersion.value,
1057
- " hasSourceMaps" -> false , // MyScalaJSPlugin .wantSourceMaps.value,
1067
+ " hasSourceMaps" -> false , // BootstrappedDottyJSPlugin .wantSourceMaps.value,
1058
1068
" isNoModule" -> (moduleKind == ModuleKind .NoModule ),
1059
1069
" isESModule" -> (moduleKind == ModuleKind .ESModule ),
1060
1070
" isCommonJSModule" -> (moduleKind == ModuleKind .CommonJSModule ),
@@ -1174,9 +1184,21 @@ object Build {
1174
1184
case Bootstrapped => scaladoc
1175
1185
}
1176
1186
1177
- lazy val `scaladoc-testcases` = project.in(file(" scaladoc-testcases" )).asScaladocTestcases
1187
+ lazy val `scaladoc-testcases` = project.in(file(" scaladoc-testcases" )).asScaladocTestcases(Bootstrapped )
1188
+ lazy val `scaladoc-testcases-nonBootstrapped` = project.in(file(" scaladoc-testcases" )).asScaladocTestcases(NonBootstrapped )
1178
1189
1179
- lazy val `scaladoc-js` = project.in(file(" scaladoc-js" )).asScaladocJs
1190
+ def scalaDocTestcases (implicit mode : Mode ): Project = mode match {
1191
+ case NonBootstrapped => `scaladoc-testcases-nonBootstrapped`
1192
+ case Bootstrapped => `scaladoc-testcases`
1193
+ }
1194
+
1195
+ lazy val `scaladoc-js` = project.in(file(" scaladoc-js" )).asScaladocJs(Bootstrapped )
1196
+ lazy val `scaladoc-js-nonBootstrapped` = project.in(file(" scaladoc-js" )).asScaladocJs(NonBootstrapped )
1197
+
1198
+ def scalaDocJs (implicit mode : Mode ): Project = mode match {
1199
+ case NonBootstrapped => `scaladoc-js-nonBootstrapped`
1200
+ case Bootstrapped => `scaladoc-js`
1201
+ }
1180
1202
1181
1203
// sbt plugin to use Dotty in your own build, see
1182
1204
// https://github.com/lampepfl/scala3-example-project for usage.
@@ -1510,42 +1532,53 @@ object Build {
1510
1532
settings(commonBenchmarkSettings).
1511
1533
enablePlugins(JmhPlugin )
1512
1534
1513
- def scaladocBasic (mode : Mode ): Project = {
1535
+ def scaladocBasic (implicit mode : Mode ): Project = {
1514
1536
val flexmarkVersion = " 0.42.12"
1515
1537
1516
- val base = if (mode == Bootstrapped )
1517
- project.settings(commonBootstrappedSettings).
1518
- dependsOn(`scala3-compiler-bootstrapped`).
1519
- dependsOn(`scala3-tasty-inspector`)
1520
- else
1521
- project.settings(commonNonBootstrappedSettings).
1522
- dependsOn(`scala3-compiler`).
1523
- dependsOn(`scala3-tasty-inspector-nonbootstrapped`)
1524
-
1525
- base.settings(
1526
- libraryDependencies ++= Seq (
1527
- " com.vladsch.flexmark" % " flexmark" % flexmarkVersion,
1528
- " com.vladsch.flexmark" % " flexmark-html-parser" % flexmarkVersion,
1529
- " com.vladsch.flexmark" % " flexmark-ext-anchorlink" % flexmarkVersion,
1530
- " com.vladsch.flexmark" % " flexmark-ext-autolink" % flexmarkVersion,
1531
- " com.vladsch.flexmark" % " flexmark-ext-emoji" % flexmarkVersion,
1532
- " com.vladsch.flexmark" % " flexmark-ext-gfm-strikethrough" % flexmarkVersion,
1533
- " com.vladsch.flexmark" % " flexmark-ext-gfm-tables" % flexmarkVersion,
1534
- " com.vladsch.flexmark" % " flexmark-ext-gfm-tasklist" % flexmarkVersion,
1535
- " com.vladsch.flexmark" % " flexmark-ext-wikilink" % flexmarkVersion,
1536
- " com.vladsch.flexmark" % " flexmark-ext-yaml-front-matter" % flexmarkVersion,
1537
- " nl.big-o" % " liqp" % " 0.6.7" ,
1538
- " org.jsoup" % " jsoup" % " 1.13.1" , // Needed to process .html files for static site
1539
- Dependencies .`jackson-dataformat-yaml`,
1540
-
1541
- " com.novocode" % " junit-interface" % " 0.11" % " test" ,
1542
- ),
1543
- Compile / mainClass := Some (" dotty.tools.scaladoc.Main" ),
1544
- Compile / buildInfoKeys := Seq [BuildInfoKey ](version),
1545
- Compile / buildInfoPackage := " dotty.tools.scaladoc" ,
1546
- BuildInfoPlugin .buildInfoScopedSettings(Compile ),
1547
- BuildInfoPlugin .buildInfoDefaultSettings,
1548
- )
1538
+ val base = if (mode == Bootstrapped )
1539
+ project.settings(commonBootstrappedSettings)
1540
+ .dependsOn(`scala3-compiler-bootstrapped`)
1541
+ .dependsOn(`scala3-tasty-inspector`)
1542
+ else
1543
+ project.settings(commonNonBootstrappedSettings)
1544
+ .dependsOn(`scala3-compiler`)
1545
+ .dependsOn(`scala3-tasty-inspector-nonbootstrapped`)
1546
+
1547
+ base.settings(
1548
+ Compile / resourceGenerators += Def .task {
1549
+ val jsDestinationFile = (Compile / resourceManaged).value / " dotty_res" / " scripts" / " searchbar.js"
1550
+ sbt.IO .copyFile((fullOptJS in Compile in scalaDocJs).value.data, jsDestinationFile)
1551
+ Seq (jsDestinationFile)
1552
+ }.taskValue,
1553
+ Compile / resourceGenerators += Def .task {
1554
+ val cssDesitnationFile = (Compile / resourceManaged).value / " dotty_res" / " styles" / " scaladoc-searchbar.css"
1555
+ val cssSourceFile = (resourceDirectory in Compile in scalaDocJs).value / " scaladoc-searchbar.css"
1556
+ sbt.IO .copyFile(cssSourceFile, cssDesitnationFile)
1557
+ Seq (cssDesitnationFile)
1558
+ }.taskValue,
1559
+ libraryDependencies ++= Seq (
1560
+ " com.vladsch.flexmark" % " flexmark" % flexmarkVersion,
1561
+ " com.vladsch.flexmark" % " flexmark-html-parser" % flexmarkVersion,
1562
+ " com.vladsch.flexmark" % " flexmark-ext-anchorlink" % flexmarkVersion,
1563
+ " com.vladsch.flexmark" % " flexmark-ext-autolink" % flexmarkVersion,
1564
+ " com.vladsch.flexmark" % " flexmark-ext-emoji" % flexmarkVersion,
1565
+ " com.vladsch.flexmark" % " flexmark-ext-gfm-strikethrough" % flexmarkVersion,
1566
+ " com.vladsch.flexmark" % " flexmark-ext-gfm-tables" % flexmarkVersion,
1567
+ " com.vladsch.flexmark" % " flexmark-ext-gfm-tasklist" % flexmarkVersion,
1568
+ " com.vladsch.flexmark" % " flexmark-ext-wikilink" % flexmarkVersion,
1569
+ " com.vladsch.flexmark" % " flexmark-ext-yaml-front-matter" % flexmarkVersion,
1570
+ " nl.big-o" % " liqp" % " 0.6.7" ,
1571
+ " org.jsoup" % " jsoup" % " 1.13.1" , // Needed to process .html files for static site
1572
+ Dependencies .`jackson-dataformat-yaml`,
1573
+
1574
+ " com.novocode" % " junit-interface" % " 0.11" % " test" ,
1575
+ ),
1576
+ Compile / mainClass := Some (" dotty.tools.scaladoc.Main" ),
1577
+ Compile / buildInfoKeys := Seq [BuildInfoKey ](version),
1578
+ Compile / buildInfoPackage := " dotty.tools.scaladoc" ,
1579
+ BuildInfoPlugin .buildInfoScopedSettings(Compile ),
1580
+ BuildInfoPlugin .buildInfoDefaultSettings,
1581
+ )
1549
1582
}
1550
1583
1551
1584
def asScaladoc : Project = {
@@ -1652,36 +1685,29 @@ object Build {
1652
1685
Build .testcasesSourceRoot.in(Test ),
1653
1686
Build .testDocumentationRoot,
1654
1687
),
1655
- Compile / resourceGenerators += Def .task {
1656
- val jsDestinationFile = (Compile / resourceManaged).value / " dotty_res" / " scripts" / " searchbar.js"
1657
- sbt.IO .copyFile((fullOptJS in Compile in `scaladoc-js`).value.data, jsDestinationFile)
1658
- Seq (jsDestinationFile)
1659
- }.taskValue,
1660
- Compile / resourceGenerators += Def .task {
1661
- val cssDesitnationFile = (Compile / resourceManaged).value / " dotty_res" / " styles" / " scaladoc-searchbar.css"
1662
- val cssSourceFile = (resourceDirectory in Compile in `scaladoc-js`).value / " scaladoc-searchbar.css"
1663
- sbt.IO .copyFile(cssSourceFile, cssDesitnationFile)
1664
- Seq (cssDesitnationFile)
1665
- }.taskValue,
1666
1688
testDocumentationRoot := (baseDirectory.value / " test-documentations" ).getAbsolutePath,
1667
1689
buildInfoPackage in Test := " dotty.tools.scaladoc.test" ,
1668
1690
BuildInfoPlugin .buildInfoScopedSettings(Test ),
1669
1691
)
1670
1692
}
1671
1693
1672
- def asScaladocTestcases : Project =
1673
- project.dependsOn(`scala3-compiler-bootstrapped`).settings(commonBootstrappedSettings)
1674
-
1675
- def asScaladocJs : Project =
1676
- project.
1677
- enablePlugins(MyScalaJSPlugin ).
1678
- dependsOn(`scala3-library-bootstrappedJS`).
1679
- settings(
1680
- fork in Test := false ,
1681
- scalaJSUseMainModuleInitializer := true ,
1682
- libraryDependencies += (" org.scala-js" %%% " scalajs-dom" % " 1.1.0" ).withDottyCompat(scalaVersion.value)
1683
- )
1684
-
1694
+ def asScaladocTestcases (implicit mode : Mode ): Project =
1695
+ if (mode == Bootstrapped )
1696
+ project.dependsOn(`scala3-compiler-bootstrapped`).settings(commonBootstrappedSettings)
1697
+ else
1698
+ project.dependsOn(`scala3-compiler`).settings(commonNonBootstrappedSettings)
1699
+
1700
+ def asScaladocJs (implicit mode : Mode ): Project = {
1701
+ val pr = if (mode == Bootstrapped )
1702
+ project.enablePlugins(BootstrappedDottyJSPlugin ).dependsOn(`scala3-library-bootstrappedJS`)
1703
+ else
1704
+ project.enablePlugins(NonBootstrappedDottyJSPlugin ).dependsOn(`scala3-library-js`)
1705
+ pr.settings(
1706
+ fork in Test := false ,
1707
+ scalaJSUseMainModuleInitializer := true ,
1708
+ libraryDependencies += (" org.scala-js" %%% " scalajs-dom" % " 1.1.0" ).withDottyCompat(scalaVersion.value)
1709
+ )
1710
+ }
1685
1711
1686
1712
def asDist (implicit mode : Mode ): Project = project.
1687
1713
enablePlugins(PackPlugin ).
0 commit comments