@@ -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
/* #11709 Remove the dependency on scala3-library that ScalaJSPlugin adds.
42
42
* Instead, in this build, we use `.dependsOn` relationships to depend on
@@ -61,6 +61,8 @@ object MyScalaJSPlugin extends AutoPlugin {
61
61
excludeFromIDE := true
62
62
)
63
63
}
64
+ object BootstrappedDottyJSPlugin extends DottyJSPlugin (Build .commonBootstrappedSettings)
65
+ object NonBootstrappedDottyJSPlugin extends DottyJSPlugin (Build .commonNonBootstrappedSettings)
64
66
65
67
object Build {
66
68
val referenceVersion = " 3.0.0-RC2-bin-20210318-e60ef35-NIGHTLY"
@@ -350,8 +352,6 @@ object Build {
350
352
},
351
353
// sbt-dotty defines `scalaInstance in doc` so we need to override it manually
352
354
doc / scalaInstance := scalaInstance.value,
353
-
354
- disableDocSetting,
355
355
)
356
356
357
357
lazy val commonBenchmarkSettings = Seq (
@@ -689,6 +689,16 @@ object Build {
689
689
case Bootstrapped => `scala3-library-bootstrapped`
690
690
}
691
691
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
+
692
702
/** The dotty standard library compiled with the Scala.js back-end, to produce
693
703
* the corresponding .sjsir files.
694
704
*
@@ -700,7 +710,7 @@ object Build {
700
710
*/
701
711
lazy val `scala3-library-bootstrappedJS` : Project = project.in(file(" library-js" )).
702
712
asDottyLibrary(Bootstrapped ).
703
- enablePlugins(MyScalaJSPlugin ).
713
+ enablePlugins(BootstrappedDottyJSPlugin ).
704
714
settings(
705
715
libraryDependencies +=
706
716
(" org.scala-js" %% " scalajs-library" % scalaJSVersion).withDottyCompat(scalaVersion.value),
@@ -981,7 +991,7 @@ object Build {
981
991
* useful, as that would not provide the linker and JS runners.
982
992
*/
983
993
lazy val sjsSandbox = project.in(file(" sandbox/scalajs" )).
984
- enablePlugins(MyScalaJSPlugin ).
994
+ enablePlugins(BootstrappedDottyJSPlugin ).
985
995
dependsOn(`scala3-library-bootstrappedJS`).
986
996
settings(
987
997
// Required to run Scala.js tests.
@@ -998,7 +1008,7 @@ object Build {
998
1008
* It will grow in the future, as more stuff is confirmed to be supported.
999
1009
*/
1000
1010
lazy val sjsJUnitTests = project.in(file(" tests/sjs-junit" )).
1001
- enablePlugins(MyScalaJSPlugin ).
1011
+ enablePlugins(BootstrappedDottyJSPlugin ).
1002
1012
dependsOn(`scala3-library-bootstrappedJS`).
1003
1013
settings(
1004
1014
scalacOptions --= Seq (" -Xfatal-warnings" , " -deprecation" ),
@@ -1056,7 +1066,7 @@ object Build {
1056
1066
(Compile / sourceManaged).value,
1057
1067
" org.scalajs.testsuite.utils.BuildInfo" ,
1058
1068
" scalaVersion" -> scalaVersion.value,
1059
- " hasSourceMaps" -> false , // MyScalaJSPlugin .wantSourceMaps.value,
1069
+ " hasSourceMaps" -> false , // BootstrappedDottyJSPlugin .wantSourceMaps.value,
1060
1070
" isNoModule" -> (moduleKind == ModuleKind .NoModule ),
1061
1071
" isESModule" -> (moduleKind == ModuleKind .ESModule ),
1062
1072
" isCommonJSModule" -> (moduleKind == ModuleKind .CommonJSModule ),
@@ -1180,9 +1190,21 @@ object Build {
1180
1190
case Bootstrapped => scaladoc
1181
1191
}
1182
1192
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 )
1184
1203
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
+ }
1186
1208
1187
1209
// sbt plugin to use Dotty in your own build, see
1188
1210
// https://github.com/lampepfl/scala3-example-project for usage.
@@ -1517,42 +1539,53 @@ object Build {
1517
1539
settings(commonBenchmarkSettings).
1518
1540
enablePlugins(JmhPlugin )
1519
1541
1520
- def scaladocBasic (mode : Mode ): Project = {
1542
+ def scaladocBasic (implicit mode : Mode ): Project = {
1521
1543
val flexmarkVersion = " 0.42.12"
1522
1544
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
+ )
1556
1589
}
1557
1590
1558
1591
def asScaladoc : Project = {
@@ -1668,36 +1701,29 @@ object Build {
1668
1701
(Test / Build .testcasesSourceRoot),
1669
1702
Build .testDocumentationRoot,
1670
1703
),
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,
1682
1704
testDocumentationRoot := (baseDirectory.value / " test-documentations" ).getAbsolutePath,
1683
1705
Test / buildInfoPackage := " dotty.tools.scaladoc.test" ,
1684
1706
BuildInfoPlugin .buildInfoScopedSettings(Test ),
1685
1707
)
1686
1708
}
1687
1709
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
+ }
1701
1727
1702
1728
def asDist (implicit mode : Mode ): Project = project.
1703
1729
enablePlugins(PackPlugin ).
0 commit comments