=pro #15031 use sbt-unidoc plugin
This commit is contained in:
parent
d84d583585
commit
7b35ded34e
5 changed files with 46 additions and 123 deletions
|
|
@ -24,7 +24,8 @@ import java.io.{PrintWriter, InputStreamReader, FileInputStream, File}
|
|||
import java.nio.charset.Charset
|
||||
import java.util.Properties
|
||||
import annotation.tailrec
|
||||
import Unidoc.{ JavaDoc, javadocSettings, junidocSources, sunidoc, unidocExclude }
|
||||
import sbtunidoc.Plugin.{ ScalaUnidoc, JavaUnidoc, scalaJavaUnidocSettings, genjavadocSettings, scalaUnidocSettings }
|
||||
import sbtunidoc.Plugin.UnidocKeys.{ unidoc, unidocProjectFilter }
|
||||
import TestExtras.{ JUnitFileReporting, StatsDMetrics }
|
||||
import com.typesafe.sbt.S3Plugin.{ S3, s3Settings }
|
||||
|
||||
|
|
@ -49,17 +50,15 @@ object AkkaBuild extends Build {
|
|||
lazy val akka = Project(
|
||||
id = "akka",
|
||||
base = file("."),
|
||||
settings = parentSettings ++ Release.settings ++ Unidoc.settings ++ Publish.versionSettings ++
|
||||
SphinxSupport.settings ++ Dist.settings ++ s3Settings ++ mimaSettings ++ unidocScaladocSettings ++
|
||||
StatsDMetrics.settings ++
|
||||
Protobuf.settings ++ inConfig(JavaDoc)(Defaults.configSettings) ++ Seq(
|
||||
settings = parentSettings ++ Release.settings ++ unidocSettings ++ Publish.versionSettings ++
|
||||
SphinxSupport.settings ++ Dist.settings ++ s3Settings ++ mimaSettings ++ scaladocSettings ++
|
||||
StatsDMetrics.settings ++ Protobuf.settings ++ inTask(unidoc)(Seq(
|
||||
unidocProjectFilter in ScalaUnidoc := docProjectFilter,
|
||||
unidocProjectFilter in JavaUnidoc := docProjectFilter,
|
||||
apiMappings in ScalaUnidoc := (apiMappings in (Compile, doc)).value
|
||||
)) ++ Seq(
|
||||
parallelExecution in GlobalScope := System.getProperty("akka.parallelExecution", "false").toBoolean,
|
||||
Publish.defaultPublishTo in ThisBuild <<= crossTarget / "repository",
|
||||
unidocExclude := Seq(samples.id, remoteTests.id),
|
||||
sources in JavaDoc <<= junidocSources,
|
||||
javacOptions in JavaDoc := Seq(),
|
||||
artifactName in packageDoc in JavaDoc := ((sv, mod, art) => "" + mod.name + "_" + sv.binary + "-" + mod.revision + "-javadoc.jar"),
|
||||
packageDoc in Compile <<= packageDoc in JavaDoc,
|
||||
Dist.distExclude := Seq(actorTests.id, docs.id, samples.id, osgi.id),
|
||||
// generate online version of docs
|
||||
sphinxInputs in Sphinx <<= sphinxInputs in Sphinx in LocalProject(docs.id) map { inputs => inputs.copy(tags = inputs.tags :+ "online") },
|
||||
|
|
@ -75,7 +74,7 @@ object AkkaBuild extends Build {
|
|||
archivesPathFinder.get.map(file => (file -> ("akka/" + file.getName)))
|
||||
},
|
||||
// add reportBinaryIssues to validatePullRequest on minor version maintenance branch
|
||||
validatePullRequest <<= (Unidoc.unidoc, SphinxSupport.generate in Sphinx in docs) map { (_, _) => }
|
||||
validatePullRequest <<= (unidoc in Compile, SphinxSupport.generate in Sphinx in docs) map { (_, _) => }
|
||||
),
|
||||
aggregate = Seq(actor, testkit, actorTests, remote, remoteTests, camel, cluster, slf4j, agent,
|
||||
persistence, zeroMQ, kernel, osgi, docs, contrib, samples, multiNodeTestkit)
|
||||
|
|
@ -725,7 +724,6 @@ object AkkaBuild extends Build {
|
|||
|
||||
) ++ mavenLocalResolverSettings ++ JUnitFileReporting.settings ++ StatsDMetrics.settings
|
||||
|
||||
|
||||
val validatePullRequest = TaskKey[Unit]("validate-pull-request", "Additional tasks for pull request validation")
|
||||
// the tasks that to run for validation is defined in defaultSettings
|
||||
val validatePullRequestTask = validatePullRequest := ()
|
||||
|
|
@ -833,6 +831,15 @@ object AkkaBuild extends Build {
|
|||
case (false, _) => Seq.empty
|
||||
})
|
||||
|
||||
val genjavadocEnabled = System.getProperty("akka.genjavadoc.enabled", "false").toBoolean
|
||||
val (unidocSettings, javadocSettings) =
|
||||
if (genjavadocEnabled) (scalaJavaUnidocSettings, genjavadocSettings)
|
||||
else (scalaUnidocSettings, Nil)
|
||||
|
||||
val docProjectFilter = inAnyProject --
|
||||
inAggregates(samples, transitive = true, includeRoot = true) --
|
||||
inProjects(remoteTests)
|
||||
|
||||
lazy val scaladocDiagramsEnabled = System.getProperty("akka.scaladoc.diagrams", "true").toBoolean
|
||||
lazy val scaladocAutoAPI = System.getProperty("akka.scaladoc.autoapi", "true").toBoolean
|
||||
|
||||
|
|
@ -855,14 +862,6 @@ object AkkaBuild extends Build {
|
|||
))
|
||||
}
|
||||
|
||||
lazy val unidocScaladocSettings: Seq[sbt.Setting[_]]= {
|
||||
inTask(doc)(Seq(
|
||||
scalacOptions <++= (version, baseDirectory in akka) map scaladocOptions,
|
||||
autoAPIMappings := scaladocAutoAPI
|
||||
)) ++
|
||||
(if (scaladocDiagramsEnabled) Seq(sunidoc ~= scaladocVerifier) else Seq.empty)
|
||||
}
|
||||
|
||||
def scaladocVerifier(file: File): File= {
|
||||
@tailrec
|
||||
def findHTMLFileWithDiagram(dirs: Seq[File]): Boolean = {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import sbt.classpath.ClasspathUtilities
|
|||
import sbt.Project.Initialize
|
||||
import java.io.File
|
||||
import com.typesafe.sbt.site.SphinxSupport.{ generate, Sphinx }
|
||||
import sbtunidoc.Plugin._
|
||||
|
||||
object Dist {
|
||||
case class DistSources(depJars: Seq[File], libJars: Seq[File], srcJars: Seq[File], docJars: Seq[File], api: File, docs: File)
|
||||
|
|
@ -29,7 +30,7 @@ object Dist {
|
|||
distLibJars <<= (thisProjectRef, buildStructure, distExclude) flatMap aggregated(packageBin.task in Compile),
|
||||
distSrcJars <<= (thisProjectRef, buildStructure, distExclude) flatMap aggregated(packageSrc.task in Compile),
|
||||
distDocJars <<= (thisProjectRef, buildStructure, distExclude) flatMap aggregated(packageDoc.task in Compile),
|
||||
distSources <<= (distDependencies, distLibJars, distSrcJars, distDocJars, Unidoc.sunidoc, generate in Sphinx in docsProject) map DistSources,
|
||||
distSources <<= (distDependencies, distLibJars, distSrcJars, distDocJars, doc in ScalaUnidoc, generate in Sphinx in docsProject) map DistSources,
|
||||
distDirectory <<= crossTarget / "dist",
|
||||
distUnzipped <<= distDirectory / "unzipped",
|
||||
distFile <<= (distDirectory, version) { (dir, v) => dir / ("akka-" + v + ".zip") },
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import java.io.File
|
|||
import com.typesafe.sbt.site.SphinxSupport.{ generate, Sphinx }
|
||||
import com.typesafe.sbt.pgp.PgpKeys.publishSigned
|
||||
import com.typesafe.sbt.S3Plugin.S3
|
||||
import sbtunidoc.Plugin.UnidocKeys._
|
||||
|
||||
object Release {
|
||||
val releaseDirectory = SettingKey[File]("release-directory")
|
||||
|
|
@ -25,7 +26,7 @@ object Release {
|
|||
val projectRef = extracted.get(thisProjectRef)
|
||||
val repo = extracted.get(Publish.defaultPublishTo)
|
||||
val state1 = extracted.runAggregated(publishSigned in projectRef, state)
|
||||
val (state2, (api, japi)) = extracted.runTask(Unidoc.unidoc, state1)
|
||||
val (state2, Seq(api, japi)) = extracted.runTask(unidoc in Compile, state1)
|
||||
val (state3, docs) = extracted.runTask(generate in Sphinx, state2)
|
||||
val (state4, dist) = extracted.runTask(Dist.dist, state3)
|
||||
val (state5, activatorDist) = extracted.runTask(ActivatorDist.activatorDist in LocalProject(AkkaBuild.samples.id), state4)
|
||||
|
|
|
|||
|
|
@ -1,80 +0,0 @@
|
|||
package akka
|
||||
|
||||
import sbt._
|
||||
import sbt.Keys._
|
||||
import sbt.Project.Initialize
|
||||
|
||||
object Unidoc {
|
||||
|
||||
lazy val JavaDoc = config("genjavadoc") extend Compile
|
||||
|
||||
lazy val GenJavaDocEnabled = Option(sys.props("akka.genjavadoc.enabled")) filter (_.toLowerCase == "true") map (_ => true) getOrElse false
|
||||
|
||||
lazy val javadocSettings =
|
||||
inConfig(JavaDoc)(Defaults.configSettings) ++
|
||||
(if (GenJavaDocEnabled) Seq(
|
||||
packageDoc in Compile <<= packageDoc in JavaDoc,
|
||||
sources in JavaDoc <<= (target, compile in Compile, sources in Compile) map ((t, c, s) =>
|
||||
(t / "java" ** "*.java").get ++ s.filter(_.getName.endsWith(".java"))
|
||||
),
|
||||
javacOptions in JavaDoc := Seq(),
|
||||
artifactName in packageDoc in JavaDoc := ((sv, mod, art) => "" + mod.name + "_" + sv.binary + "-" + mod.revision + "-javadoc.jar"),
|
||||
libraryDependencies += Dependencies.Compile.genjavadoc,
|
||||
scalacOptions <+= target map (t => "-P:genjavadoc:out=" + (t / "java"))
|
||||
) else Nil)
|
||||
|
||||
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, File)]("unidoc", "Create unified scaladoc and javadoc for all aggregates")
|
||||
val sunidoc = TaskKey[File]("sunidoc", "Create unified scaladoc for all aggregates")
|
||||
val junidoc = TaskKey[File]("junidoc", "Create unified javadoc for all aggregates")
|
||||
val junidocAllSources = TaskKey[Seq[Seq[File]]]("junidoc-all-sources")
|
||||
val junidocSources = TaskKey[Seq[File]]("junidoc-sources")
|
||||
|
||||
lazy val settings = Seq(
|
||||
unidocDirectory <<= crossTarget / "unidoc",
|
||||
unidocExclude := Seq.empty,
|
||||
unidocAllSources <<= (thisProjectRef, buildStructure, unidocExclude) flatMap allSources(Compile),
|
||||
unidocSources <<= unidocAllSources map { _.flatten },
|
||||
unidocAllClasspaths <<= (thisProjectRef, buildStructure, unidocExclude) flatMap allClasspaths,
|
||||
unidocClasspath <<= unidocAllClasspaths map { _.flatten.map(_.data).distinct },
|
||||
junidocAllSources <<= (thisProjectRef, buildStructure, unidocExclude) flatMap allSources(JavaDoc),
|
||||
junidocSources <<= junidocAllSources map { _.flatten },
|
||||
sunidoc <<= sunidocTask,
|
||||
junidoc <<= (doc in JavaDoc),
|
||||
unidoc <<= (sunidoc, junidoc) map ((s, t) ⇒ (s, t))
|
||||
)
|
||||
|
||||
def allSources(conf: Configuration)(projectRef: ProjectRef, structure: Load.BuildStructure, exclude: Seq[String]): Task[Seq[Seq[File]]] = {
|
||||
val projects = aggregated(projectRef, structure, exclude)
|
||||
projects flatMap { sources in conf 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 sunidocTask: Initialize[Task[File]] = {
|
||||
(compilers, cacheDirectory, unidocSources, unidocClasspath, unidocDirectory, scalacOptions in doc, apiMappings in (Compile, doc), streams) map {
|
||||
(compilers, cache, sources, classpath, target, options, api, s) => {
|
||||
val scaladoc = new Scaladoc(100, compilers.scalac)
|
||||
val opts1 = options ++ Opts.doc.externalAPI(api)
|
||||
scaladoc.cached(cache / "unidoc", "main", sources, classpath, target, opts1, s.log)
|
||||
target
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -18,4 +18,6 @@ addSbtPlugin("com.typesafe.sbt" % "sbt-pgp" % "0.8.1")
|
|||
|
||||
addSbtPlugin("com.typesafe.sbt" % "sbt-s3" % "0.5")
|
||||
|
||||
addSbtPlugin("com.eed3si9n" % "sbt-unidoc" % "0.3.1")
|
||||
|
||||
libraryDependencies += "com.timgroup" % "java-statsd-client" % "2.0.0"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue