Skip to content

Commit 193c572

Browse files
committed
sbt-dotty: Don't break scaladoc in non-Dotty projects
Also fix `test:doc` for Dotty projects: we were only passing `-project` to dottydoc for `compile:doc`. Dottydoc is still probably not working correctly in user projects but I'll let whoever takes over its maintainership handle that.
1 parent f95ac7a commit 193c572

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,6 @@ object DottyPlugin extends AutoPlugin {
153153
scalaOrganization.value
154154
},
155155

156-
scalacOptions in (Compile, doc) ++= Seq("-project", name.value),
157-
158156
incOptions in Compile := {
159157
val inc = (incOptions in Compile).value
160158
if (isDotty.value)
@@ -326,13 +324,32 @@ object DottyPlugin extends AutoPlugin {
326324
}
327325

328326
private val docSettings = inTask(doc)(Seq(
329-
sources := {
330-
val _ = compile.value // Ensure that everything is compiled, so TASTy is available.
331-
val prev = sources.value
332-
val tastyFiles = (classDirectory.value ** "*.tasty").get.map(_.getAbsoluteFile)
333-
prev ++ tastyFiles
334-
},
335-
scalacOptions += "-from-tasty"
327+
sources := Def.taskDyn {
328+
val old = sources.value
329+
330+
if (isDotty.value) Def.task {
331+
val _ = compile.value // Ensure that everything is compiled, so TASTy is available.
332+
val tastyFiles = (classDirectory.value ** "*.tasty").get.map(_.getAbsoluteFile)
333+
old ++ tastyFiles
334+
} else Def.task {
335+
old
336+
}
337+
}.value,
338+
scalacOptions ++= {
339+
if (isDotty.value) {
340+
val projectName =
341+
if (configuration.value == Compile)
342+
name.value
343+
else
344+
s"${name.value}-${configuration.value}"
345+
Seq(
346+
"-project", projectName,
347+
"-from-tasty"
348+
)
349+
}
350+
else
351+
Seq()
352+
}
336353
))
337354

338355
/** Fetch artifacts for moduleID */

0 commit comments

Comments
 (0)