Add unified scaladoc to sbt build
This commit is contained in:
parent
5776362f70
commit
8947a69df3
2 changed files with 54 additions and 1 deletions
|
|
@ -10,7 +10,9 @@ object AkkaBuild extends Build {
|
|||
lazy val akka = Project(
|
||||
id = "akka",
|
||||
base = file("."),
|
||||
settings = buildSettings,
|
||||
settings = buildSettings ++ Unidoc.settings ++ Seq(
|
||||
Unidoc.unidocExclude := Seq(samples.id, tutorials.id)
|
||||
),
|
||||
aggregate = Seq(actor, testkit, actorTests, stm, cluster, http, slf4j, mailboxes, camel, camelTyped, samples, tutorials)
|
||||
)
|
||||
|
||||
|
|
|
|||
51
project/Unidoc.scala
Normal file
51
project/Unidoc.scala
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
import sbt._
|
||||
import Keys._
|
||||
import Project.Initialize
|
||||
|
||||
object Unidoc {
|
||||
val unidocDirectory = SettingKey[File]("unidoc-directory")
|
||||
val unidocExclude = SettingKey[Seq[String]]("unidoc-exclude")
|
||||
val unidocAllSources = TaskKey[Seq[Seq[File]]]("unidoc-all-sources")
|
||||
val unidocSources = TaskKey[Seq[File]]("unidoc-sources")
|
||||
val unidocAllClasspaths = TaskKey[Seq[Classpath]]("unidoc-all-classpaths")
|
||||
val unidocClasspath = TaskKey[Seq[File]]("unidoc-classpath")
|
||||
val unidoc = TaskKey[File]("unidoc", "Create unified scaladoc for all aggregates")
|
||||
|
||||
lazy val settings = Seq(
|
||||
unidocDirectory <<= crossTarget / "unidoc",
|
||||
unidocExclude := Seq.empty,
|
||||
unidocAllSources <<= (thisProjectRef, buildStructure, unidocExclude) flatMap allSources,
|
||||
unidocSources <<= unidocAllSources map { _.flatten },
|
||||
unidocAllClasspaths <<= (thisProjectRef, buildStructure, unidocExclude) flatMap allClasspaths,
|
||||
unidocClasspath <<= unidocAllClasspaths map { _.flatten.map(_.data).distinct },
|
||||
unidoc <<= unidocTask
|
||||
)
|
||||
|
||||
def allSources(projectRef: ProjectRef, structure: Load.BuildStructure, exclude: Seq[String]): Task[Seq[Seq[File]]] = {
|
||||
val projects = aggregated(projectRef, structure, exclude)
|
||||
projects flatMap { sources in Compile in LocalProject(_) get structure.data } join
|
||||
}
|
||||
|
||||
def allClasspaths(projectRef: ProjectRef, structure: Load.BuildStructure, exclude: Seq[String]): Task[Seq[Classpath]] = {
|
||||
val projects = aggregated(projectRef, structure, exclude)
|
||||
projects flatMap { dependencyClasspath in Compile in LocalProject(_) get structure.data } join
|
||||
}
|
||||
|
||||
def aggregated(projectRef: ProjectRef, structure: Load.BuildStructure, exclude: Seq[String]): Seq[String] = {
|
||||
val aggregate = Project.getProject(projectRef, structure).toSeq.flatMap(_.aggregate)
|
||||
aggregate flatMap { ref =>
|
||||
if (exclude contains ref.project) Seq.empty
|
||||
else ref.project +: aggregated(ref, structure, exclude)
|
||||
}
|
||||
}
|
||||
|
||||
def unidocTask: Initialize[Task[File]] = {
|
||||
(compilers, cacheDirectory, unidocSources, unidocClasspath, unidocDirectory, scaladocOptions in Compile, streams) map {
|
||||
(compilers, cache, sources, classpath, target, options, s) => {
|
||||
val scaladoc = new Scaladoc(100, compilers.scalac)
|
||||
scaladoc.cached(cache / "unidoc", "main", sources, classpath, target, options, s.log)
|
||||
target
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue