@@ -519,6 +519,34 @@ object Build {
519519 enableBspAllProjectsFile.exists()
520520 }
521521
522+ // Setups up doc / scalaInstance to use in the bootstrapped projects instead of the default one
523+ lazy val scaladocDerivedInstanceSettings = Def .settings(
524+ // We cannot include scaladoc in the regular `scalaInstance` task because
525+ // it's a bootstrapped-only project, so we would run into a loop since we
526+ // need the output of that task to compile scaladoc. But we can include it
527+ // in the `scalaInstance` of the `doc` task which allows us to run
528+ // `scala3-library-bootstrapped/doc` for example.
529+ doc / scalaInstance := {
530+ val externalDeps = (LocalProject (" scaladoc-new" ) / Compile / externalDependencyClasspath).value.map(_.data)
531+ val scalaDoc = (LocalProject (" scaladoc-new" ) / Compile / packageBin).value
532+ val docJars = Array (scalaDoc) ++ externalDeps
533+
534+ val base = scalaInstance.value
535+ val docScalaInstance = Defaults .makeScalaInstance(
536+ version = base.version,
537+ libraryJars = base.libraryJars,
538+ allCompilerJars = base.compilerJars,
539+ allDocJars = docJars,
540+ state.value,
541+ scalaInstanceTopLoader.value
542+ )
543+ // assert that sbt reuses the same compiler class loader
544+ assert(docScalaInstance.loaderCompilerOnly == base.loaderCompilerOnly)
545+ docScalaInstance
546+ },
547+ Compile / doc / scalacOptions ++= scalacOptionsDocSettings(),
548+ )
549+
522550 // Settings used when compiling dotty with a non-bootstrapped dotty
523551 lazy val commonBootstrappedSettings = commonDottySettings ++ Seq (
524552 // To enable support of scaladoc and language-server projects you need to change this to true
@@ -1650,7 +1678,7 @@ object Build {
16501678 ),
16511679 // Packaging configuration of `scala3-sbt-bridge`
16521680 Compile / packageBin / publishArtifact := true ,
1653- Compile / packageDoc / publishArtifact := false ,
1681+ Compile / packageDoc / publishArtifact := true ,
16541682 Compile / packageSrc / publishArtifact := true ,
16551683 // Only publish compilation artifacts, no test artifacts
16561684 Test / publishArtifact := false ,
@@ -1682,6 +1710,7 @@ object Build {
16821710 scalaInstanceTopLoader.value
16831711 )
16841712 },
1713+ scaladocDerivedInstanceSettings,
16851714 scalaCompilerBridgeBinaryJar := {
16861715 Some ((`scala3-sbt-bridge-nonbootstrapped` / Compile / packageBin).value)
16871716 },
@@ -1712,7 +1741,7 @@ object Build {
17121741 Compile / scalacOptions ++= Seq (" --java-output-version" , Versions .minimumJVMVersion),
17131742 // Packaging configuration of `scala3-staging`
17141743 Compile / packageBin / publishArtifact := true ,
1715- Compile / packageDoc / publishArtifact := false ,
1744+ Compile / packageDoc / publishArtifact := true ,
17161745 Compile / packageSrc / publishArtifact := true ,
17171746 // Only publish compilation artifacts, no test artifacts
17181747 Test / publishArtifact := false ,
@@ -1740,6 +1769,7 @@ object Build {
17401769 scalaInstanceTopLoader.value
17411770 )
17421771 },
1772+ scaladocDerivedInstanceSettings,
17431773 scalaCompilerBridgeBinaryJar := {
17441774 Some ((`scala3-sbt-bridge-nonbootstrapped` / Compile / packageBin).value)
17451775 },
@@ -1770,7 +1800,7 @@ object Build {
17701800 Compile / scalacOptions ++= Seq (" --java-output-version" , Versions .minimumJVMVersion),
17711801 // Packaging configuration of `scala3-staging`
17721802 Compile / packageBin / publishArtifact := true ,
1773- Compile / packageDoc / publishArtifact := false ,
1803+ Compile / packageDoc / publishArtifact := true ,
17741804 Compile / packageSrc / publishArtifact := true ,
17751805 // Only publish compilation artifacts, no test artifacts
17761806 Test / publishArtifact := false ,
@@ -1798,6 +1828,7 @@ object Build {
17981828 scalaInstanceTopLoader.value
17991829 )
18001830 },
1831+ scaladocDerivedInstanceSettings,
18011832 scalaCompilerBridgeBinaryJar := {
18021833 Some ((`scala3-sbt-bridge-nonbootstrapped` / Compile / packageBin).value)
18031834 },
@@ -1826,7 +1857,7 @@ object Build {
18261857 Compile / scalacOptions ++= Seq (" --java-output-version" , Versions .minimumJVMVersion),
18271858 // Packaging configuration of `scala3-staging`
18281859 Compile / packageBin / publishArtifact := true ,
1829- Compile / packageDoc / publishArtifact := false ,
1860+ Compile / packageDoc / publishArtifact := true ,
18301861 Compile / packageSrc / publishArtifact := true ,
18311862 // Only publish compilation artifacts, no test artifacts
18321863 Test / publishArtifact := false ,
@@ -1863,6 +1894,7 @@ object Build {
18631894 scalaInstanceTopLoader.value
18641895 )
18651896 },
1897+ scaladocDerivedInstanceSettings,
18661898 scalaCompilerBridgeBinaryJar := {
18671899 Some ((`scala3-sbt-bridge-nonbootstrapped` / Compile / packageBin).value)
18681900 },
@@ -1997,6 +2029,7 @@ object Build {
19972029 lazy val `scala-library-bootstrapped` = project.in(file(" library" ))
19982030 .enablePlugins(ScalaLibraryPlugin )
19992031 .settings(publishSettings)
2032+ .settings(disableDocSetting) // TODO now produces empty JAR to satisfy Sonatype, see https://github.com/scala/scala3/issues/24434
20002033 .settings(
20012034 name := " scala-library-bootstrapped" ,
20022035 moduleName := " scala-library" ,
@@ -2028,7 +2061,7 @@ object Build {
20282061 Compile / scalacOptions ++= Seq (" --java-output-version" , Versions .minimumJVMVersion),
20292062 // Packaging configuration of the stdlib
20302063 Compile / packageBin / publishArtifact := true ,
2031- Compile / packageDoc / publishArtifact := false ,
2064+ Compile / packageDoc / publishArtifact := true ,
20322065 Compile / packageSrc / publishArtifact := true ,
20332066 // Only publish compilation artifacts, no test artifacts
20342067 Test / publishArtifact := false ,
@@ -2061,6 +2094,7 @@ object Build {
20612094 scalaInstanceTopLoader.value
20622095 )
20632096 },
2097+ scaladocDerivedInstanceSettings,
20642098 scalaCompilerBridgeBinaryJar := {
20652099 Some ((`scala3-sbt-bridge-nonbootstrapped` / Compile / packageBin).value)
20662100 },
@@ -2160,7 +2194,7 @@ object Build {
21602194 Compile / scalacOptions += " -scalajs" ,
21612195 // Packaging configuration of the stdlib
21622196 Compile / packageBin / publishArtifact := true ,
2163- Compile / packageDoc / publishArtifact := false ,
2197+ Compile / packageDoc / publishArtifact := true ,
21642198 Compile / packageSrc / publishArtifact := true ,
21652199 // Only publish compilation artifacts, no test artifacts
21662200 Test / publishArtifact := false ,
@@ -2221,6 +2255,7 @@ object Build {
22212255 scalaInstanceTopLoader.value
22222256 )
22232257 },
2258+ scaladocDerivedInstanceSettings,
22242259 scalaCompilerBridgeBinaryJar := {
22252260 Some ((`scala3-sbt-bridge-nonbootstrapped` / Compile / packageBin).value)
22262261 },
@@ -2384,7 +2419,7 @@ object Build {
23842419 ),
23852420 // Packaging configuration of the stdlib
23862421 Compile / packageBin / publishArtifact := true ,
2387- Compile / packageDoc / publishArtifact := false ,
2422+ Compile / packageDoc / publishArtifact := true ,
23882423 Compile / packageSrc / publishArtifact := true ,
23892424 // Only publish compilation artifacts, no test artifacts
23902425 Test / publishArtifact := false ,
@@ -2415,6 +2450,7 @@ object Build {
24152450 scalaInstanceTopLoader.value
24162451 )
24172452 },
2453+ scaladocDerivedInstanceSettings,
24182454 scalaCompilerBridgeBinaryJar := {
24192455 Some ((`scala3-sbt-bridge-nonbootstrapped` / Compile / packageBin).value)
24202456 },
@@ -2620,7 +2656,7 @@ object Build {
26202656 packageOptions += ManifestAttributes ((" Git-Hash" , VersionUtil .gitHash)), // Used by the REPL
26212657 // Packaging configuration of the stdlib
26222658 Compile / packageBin / publishArtifact := true ,
2623- Compile / packageDoc / publishArtifact := false ,
2659+ Compile / packageDoc / publishArtifact := true ,
26242660 Compile / packageSrc / publishArtifact := true ,
26252661 // Only publish compilation artifacts, no test artifacts
26262662 Test / publishArtifact := false ,
@@ -2654,6 +2690,7 @@ object Build {
26542690 scalaInstanceTopLoader.value
26552691 )
26562692 },
2693+ scaladocDerivedInstanceSettings,
26572694 scalaCompilerBridgeBinaryJar := {
26582695 Some ((`scala3-sbt-bridge-nonbootstrapped` / Compile / packageBin).value)
26592696 },
@@ -2774,7 +2811,7 @@ object Build {
27742811 Compile / scalacOptions ++= Seq (" --java-output-version" , Versions .minimumJVMVersion),
27752812 // Packaging configuration of the stdlib
27762813 Compile / packageBin / publishArtifact := true ,
2777- Compile / packageDoc / publishArtifact := false ,
2814+ Compile / packageDoc / publishArtifact := true ,
27782815 Compile / packageSrc / publishArtifact := true ,
27792816 // Only publish compilation artifacts, no test artifacts
27802817 Test / publishArtifact := false ,
@@ -2787,6 +2824,7 @@ object Build {
27872824 BuildInfoPlugin .buildInfoScopedSettings(Compile ),
27882825 BuildInfoPlugin .buildInfoDefaultSettings,
27892826 // Configure to use the non-bootstrapped compiler
2827+ scaladocDerivedInstanceSettings,
27902828 scalaInstance := {
27912829 val externalCompilerDeps = (`scala3-compiler-nonbootstrapped` / Compile / externalDependencyClasspath).value.map(_.data).toSet
27922830
0 commit comments