[2.x] fix: Preserve user-defined scalacOptions in doc task scope (#8528)

Fixes #7482
This commit is contained in:
MkDev11 2026-01-14 00:57:42 -05:00 committed by GitHub
parent 82e370b4cb
commit 7b33362245
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 15 additions and 8 deletions

View File

@ -1992,19 +1992,14 @@ object Defaults extends BuildCommon {
else Map.empty[HashedVirtualFileRef, URI]
},
fileInputOptions := Seq("-doc-root-content", "-diagrams-dot-path"),
scalacOptions := {
val compileOptions = scalacOptions.value
scalacOptions ++= {
val sv = scalaVersion.value
val config = configuration.value
val projectName = name.value
if (ScalaArtifacts.isScala3(sv)) {
val project = if (config == Compile) projectName else s"$projectName-$config"
if (scalaVersion.value.startsWith("3.0.0")) {
Seq("-project", project)
} else {
compileOptions ++ Seq("-project", project)
}
} else compileOptions
Seq("-project", project)
} else Seq.empty
},
(TaskZero / key) := Def.uncached {
val s = streams.value

View File

@ -0,0 +1,9 @@
lazy val root = (project in file("."))
.settings(
scalaVersion := "2.13.12",
Compile / doc / scalacOptions += "-no-link-warnings",
TaskKey[Unit]("checkDocOptions") := {
val opts = (Compile / doc / scalacOptions).value
assert(opts.contains("-no-link-warnings"), s"Expected -no-link-warnings in doc scalacOptions but got: $opts")
}
)

View File

@ -0,0 +1,3 @@
# Verify that Compile / doc / scalacOptions += works correctly
# This tests the fix for issue #7482
> checkDocOptions