From 79a760dbb19f65122b567da0c030a1d57a8b8a3f Mon Sep 17 00:00:00 2001 From: Grzegorz Kossakowski Date: Fri, 20 Feb 2015 19:04:07 +0100 Subject: Scaladoc Put library class files to scaladoc's classpath when documenting the library. TODO: why is this needed? Bug in scaladoc? Pass `src/library-aux` to scaladoc using `-doc-no-compile` option. To mimic ant, output docs into `buildDirectory/scaladoc/$name`. --- build.sbt | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'build.sbt') diff --git a/build.sbt b/build.sbt index 6c601219ec..19ada760f5 100644 --- a/build.sbt +++ b/build.sbt @@ -71,6 +71,7 @@ lazy val commonSettings = Seq[Setting[_]]( scalaSource in Compile := (sourceDirectory in Compile).value, javaSource in Compile := (sourceDirectory in Compile).value, target := (baseDirectory in ThisBuild).value / "target" / name.value, + target in Compile in doc := buildDirectory.value / "scaladoc" / name.value, classDirectory in Compile := buildDirectory.value / "quick/classes" / name.value, // given that classDirectory is overriden to be _outside_ of target directory, we have // to make sure its being cleaned properly @@ -96,7 +97,18 @@ lazy val scalaSubprojectSettings = commonSettings ++ Seq[Setting[_]]( lazy val library = configureAsSubproject(project). settings( - scalacOptions ++= Seq[String]("-sourcepath", (scalaSource in Compile).value.toString) + scalacOptions in Compile ++= Seq[String]("-sourcepath", (scalaSource in Compile).value.toString), + // Workaround for a bug in `scaladoc` that it seems to not respect the `-sourcepath` option + // as a result of this bug, the compiler cannot even initialize Definitions without + // binaries of the library on the classpath. Specifically, we get this error: + // (library/compile:doc) scala.reflect.internal.FatalError: package class scala does not have a member Int + // Ant build does the same thing always: it puts binaries for documented classes on the classpath + // sbt never does this by default (which seems like a good default) + dependencyClasspath in Compile in doc += (classDirectory in Compile).value, + scalacOptions in Compile in doc ++= { + val libraryAuxDir = (baseDirectory in ThisBuild).value / "src/library-aux" + Seq("-doc-no-compile", libraryAuxDir.toString) + } ) dependsOn (forkjoin) lazy val reflect = configureAsSubproject(project). -- cgit v1.2.3