@@ -516,6 +516,34 @@ object Build {
516516 enableBspAllProjectsFile.exists()
517517 }
518518
519+ // Setups up doc / scalaInstance to use in the bootstrapped projects instead of the default one
520+ lazy val scaladocDerivedInstanceSettings = Def .settings(
521+ // We cannot include scaladoc in the regular `scalaInstance` task because
522+ // it's a bootstrapped-only project, so we would run into a loop since we
523+ // need the output of that task to compile scaladoc. But we can include it
524+ // in the `scalaInstance` of the `doc` task which allows us to run
525+ // `scala3-library-bootstrapped/doc` for example.
526+ doc / scalaInstance := {
527+ val externalDeps = (LocalProject (" scaladoc-new" ) / Compile / externalDependencyClasspath).value.map(_.data)
528+ val scalaDoc = (LocalProject (" scaladoc-new" ) / Compile / packageBin).value
529+ val docJars = Array (scalaDoc) ++ externalDeps
530+
531+ val base = scalaInstance.value
532+ val docScalaInstance = Defaults .makeScalaInstance(
533+ version = base.version,
534+ libraryJars = base.libraryJars,
535+ allCompilerJars = base.compilerJars,
536+ allDocJars = docJars,
537+ state.value,
538+ scalaInstanceTopLoader.value
539+ )
540+ // assert that sbt reuses the same compiler class loader
541+ assert(docScalaInstance.loaderCompilerOnly == base.loaderCompilerOnly)
542+ docScalaInstance
543+ },
544+ Compile / doc / scalacOptions ++= scalacOptionsDocSettings(),
545+ )
546+
519547 // Settings used when compiling dotty with a non-bootstrapped dotty
520548 lazy val commonBootstrappedSettings = commonDottySettings ++ Seq (
521549 // To enable support of scaladoc and language-server projects you need to change this to true
@@ -1647,7 +1675,7 @@ object Build {
16471675 ),
16481676 // Packaging configuration of `scala3-sbt-bridge`
16491677 Compile / packageBin / publishArtifact := true ,
1650- Compile / packageDoc / publishArtifact := false ,
1678+ Compile / packageDoc / publishArtifact := true ,
16511679 Compile / packageSrc / publishArtifact := true ,
16521680 // Only publish compilation artifacts, no test artifacts
16531681 Test / publishArtifact := false ,
@@ -1679,6 +1707,7 @@ object Build {
16791707 scalaInstanceTopLoader.value
16801708 )
16811709 },
1710+ scaladocDerivedInstanceSettings,
16821711 scalaCompilerBridgeBinaryJar := {
16831712 Some ((`scala3-sbt-bridge-nonbootstrapped` / Compile / packageBin).value)
16841713 },
@@ -1709,7 +1738,7 @@ object Build {
17091738 Compile / scalacOptions ++= Seq (" --java-output-version" , Versions .minimumJVMVersion),
17101739 // Packaging configuration of `scala3-staging`
17111740 Compile / packageBin / publishArtifact := true ,
1712- Compile / packageDoc / publishArtifact := false ,
1741+ Compile / packageDoc / publishArtifact := true ,
17131742 Compile / packageSrc / publishArtifact := true ,
17141743 // Only publish compilation artifacts, no test artifacts
17151744 Test / publishArtifact := false ,
@@ -1737,6 +1766,7 @@ object Build {
17371766 scalaInstanceTopLoader.value
17381767 )
17391768 },
1769+ scaladocDerivedInstanceSettings,
17401770 scalaCompilerBridgeBinaryJar := {
17411771 Some ((`scala3-sbt-bridge-nonbootstrapped` / Compile / packageBin).value)
17421772 },
@@ -1767,7 +1797,7 @@ object Build {
17671797 Compile / scalacOptions ++= Seq (" --java-output-version" , Versions .minimumJVMVersion),
17681798 // Packaging configuration of `scala3-staging`
17691799 Compile / packageBin / publishArtifact := true ,
1770- Compile / packageDoc / publishArtifact := false ,
1800+ Compile / packageDoc / publishArtifact := true ,
17711801 Compile / packageSrc / publishArtifact := true ,
17721802 // Only publish compilation artifacts, no test artifacts
17731803 Test / publishArtifact := false ,
@@ -1795,6 +1825,7 @@ object Build {
17951825 scalaInstanceTopLoader.value
17961826 )
17971827 },
1828+ scaladocDerivedInstanceSettings,
17981829 scalaCompilerBridgeBinaryJar := {
17991830 Some ((`scala3-sbt-bridge-nonbootstrapped` / Compile / packageBin).value)
18001831 },
@@ -1823,7 +1854,7 @@ object Build {
18231854 Compile / scalacOptions ++= Seq (" --java-output-version" , Versions .minimumJVMVersion),
18241855 // Packaging configuration of `scala3-staging`
18251856 Compile / packageBin / publishArtifact := true ,
1826- Compile / packageDoc / publishArtifact := false ,
1857+ Compile / packageDoc / publishArtifact := true ,
18271858 Compile / packageSrc / publishArtifact := true ,
18281859 // Only publish compilation artifacts, no test artifacts
18291860 Test / publishArtifact := false ,
@@ -1860,6 +1891,7 @@ object Build {
18601891 scalaInstanceTopLoader.value
18611892 )
18621893 },
1894+ scaladocDerivedInstanceSettings,
18631895 scalaCompilerBridgeBinaryJar := {
18641896 Some ((`scala3-sbt-bridge-nonbootstrapped` / Compile / packageBin).value)
18651897 },
@@ -2025,7 +2057,7 @@ object Build {
20252057 Compile / scalacOptions ++= Seq (" --java-output-version" , Versions .minimumJVMVersion),
20262058 // Packaging configuration of the stdlib
20272059 Compile / packageBin / publishArtifact := true ,
2028- Compile / packageDoc / publishArtifact := false ,
2060+ Compile / packageDoc / publishArtifact := true ,
20292061 Compile / packageSrc / publishArtifact := true ,
20302062 // Only publish compilation artifacts, no test artifacts
20312063 Test / publishArtifact := false ,
@@ -2058,6 +2090,7 @@ object Build {
20582090 scalaInstanceTopLoader.value
20592091 )
20602092 },
2093+ scaladocDerivedInstanceSettings,
20612094 scalaCompilerBridgeBinaryJar := {
20622095 Some ((`scala3-sbt-bridge-nonbootstrapped` / Compile / packageBin).value)
20632096 },
@@ -2157,7 +2190,7 @@ object Build {
21572190 Compile / scalacOptions += " -scalajs" ,
21582191 // Packaging configuration of the stdlib
21592192 Compile / packageBin / publishArtifact := true ,
2160- Compile / packageDoc / publishArtifact := false ,
2193+ Compile / packageDoc / publishArtifact := true ,
21612194 Compile / packageSrc / publishArtifact := true ,
21622195 // Only publish compilation artifacts, no test artifacts
21632196 Test / publishArtifact := false ,
@@ -2218,6 +2251,7 @@ object Build {
22182251 scalaInstanceTopLoader.value
22192252 )
22202253 },
2254+ scaladocDerivedInstanceSettings,
22212255 scalaCompilerBridgeBinaryJar := {
22222256 Some ((`scala3-sbt-bridge-nonbootstrapped` / Compile / packageBin).value)
22232257 },
@@ -2381,7 +2415,7 @@ object Build {
23812415 ),
23822416 // Packaging configuration of the stdlib
23832417 Compile / packageBin / publishArtifact := true ,
2384- Compile / packageDoc / publishArtifact := false ,
2418+ Compile / packageDoc / publishArtifact := true ,
23852419 Compile / packageSrc / publishArtifact := true ,
23862420 // Only publish compilation artifacts, no test artifacts
23872421 Test / publishArtifact := false ,
@@ -2412,6 +2446,7 @@ object Build {
24122446 scalaInstanceTopLoader.value
24132447 )
24142448 },
2449+ scaladocDerivedInstanceSettings,
24152450 scalaCompilerBridgeBinaryJar := {
24162451 Some ((`scala3-sbt-bridge-nonbootstrapped` / Compile / packageBin).value)
24172452 },
@@ -2617,7 +2652,7 @@ object Build {
26172652 packageOptions += ManifestAttributes ((" Git-Hash" , VersionUtil .gitHash)), // Used by the REPL
26182653 // Packaging configuration of the stdlib
26192654 Compile / packageBin / publishArtifact := true ,
2620- Compile / packageDoc / publishArtifact := false ,
2655+ Compile / packageDoc / publishArtifact := true ,
26212656 Compile / packageSrc / publishArtifact := true ,
26222657 // Only publish compilation artifacts, no test artifacts
26232658 Test / publishArtifact := false ,
@@ -2651,6 +2686,7 @@ object Build {
26512686 scalaInstanceTopLoader.value
26522687 )
26532688 },
2689+ scaladocDerivedInstanceSettings,
26542690 scalaCompilerBridgeBinaryJar := {
26552691 Some ((`scala3-sbt-bridge-nonbootstrapped` / Compile / packageBin).value)
26562692 },
@@ -2771,7 +2807,7 @@ object Build {
27712807 Compile / scalacOptions ++= Seq (" --java-output-version" , Versions .minimumJVMVersion),
27722808 // Packaging configuration of the stdlib
27732809 Compile / packageBin / publishArtifact := true ,
2774- Compile / packageDoc / publishArtifact := false ,
2810+ Compile / packageDoc / publishArtifact := true ,
27752811 Compile / packageSrc / publishArtifact := true ,
27762812 // Only publish compilation artifacts, no test artifacts
27772813 Test / publishArtifact := false ,
@@ -2784,6 +2820,7 @@ object Build {
27842820 BuildInfoPlugin .buildInfoScopedSettings(Compile ),
27852821 BuildInfoPlugin .buildInfoDefaultSettings,
27862822 // Configure to use the non-bootstrapped compiler
2823+ scaladocDerivedInstanceSettings,
27872824 scalaInstance := {
27882825 val externalCompilerDeps = (`scala3-compiler-nonbootstrapped` / Compile / externalDependencyClasspath).value.map(_.data).toSet
27892826
0 commit comments