Publish paradox/japi/api (snapshot) docs via sbt (#28828)

* Publish paradox/japi/api (snapshot) docs via sbt

* Removes the need for custom release commands

* Use ++= instead of :=
This commit is contained in:
Arnout Engelen 2020-03-30 16:48:15 +02:00 committed by GitHub
parent 60ec32439c
commit 1a529aa38a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 33 additions and 90 deletions

View file

@ -75,6 +75,7 @@ lazy val aggregatedProjects: Seq[ProjectReference] = List[ProjectReference](
lazy val root = Project(id = "akka", base = file("."))
.aggregate(aggregatedProjects: _*)
.enablePlugins(DeployRsync)
.settings(rootSettings: _*)
.settings(unidocRootIgnoreProjects := Seq(remoteTests, benchJmh, protobuf, protobufV3, akkaScalaNightly, docs))
.settings(unmanagedSources in (Compile, headerCreate) := (baseDirectory.value / "project").**("*.scala").get)

View file

@ -30,7 +30,6 @@ object AkkaBuild {
Dependencies.Versions)
lazy val rootSettings = Def.settings(
Release.settings,
UnidocRoot.akkaSettings,
Protobuf.settings,
parallelExecution in GlobalScope := System.getProperty("akka.parallelExecution", parallelExecutionByDefault.toString).toBoolean,

View file

@ -12,6 +12,7 @@ import sbtunidoc.GenJavadocPlugin.autoImport._
import sbt.Keys._
import sbt.File
import scala.annotation.tailrec
import DeployRsync.autoImport.deployRsyncArtifacts
import sbt.ScopeFilter.ProjectFilter
@ -23,7 +24,7 @@ object Scaladoc extends AutoPlugin {
}
override def trigger = allRequirements
override def requires = plugins.JvmPlugin
override def requires = plugins.JvmPlugin && DeployRsync
val validateDiagrams = settingKey[Boolean]("Validate generated scaladoc diagrams")
@ -132,10 +133,22 @@ object UnidocRoot extends AutoPlugin {
.getOrElse(sbtunidoc.ScalaUnidocPlugin)
val akkaSettings = UnidocRoot.CliOptions.genjavadocEnabled
.ifTrue(Seq(javacOptions in (JavaUnidoc, unidoc) := {
.ifTrue(Seq(
javacOptions in (JavaUnidoc, unidoc) := {
if (JdkOptions.isJdk8) Seq("-Xdoclint:none")
else Seq("-Xdoclint:none", "--ignore-source-errors", "--no-module-directories")
}))
},
deployRsyncArtifacts ++= {
val releaseVersion = if (isSnapshot.value) "snapshot" else version.value
(Compile / unidoc).value match {
case Seq(japi, api) =>
Seq(
(japi -> s"www/japi/akka/$releaseVersion"),
(api -> s"www/api/akka/$releaseVersion")
)
}
}
))
.getOrElse(Nil)
override lazy val projectSettings = {

View file

@ -7,6 +7,7 @@ package akka
import com.lightbend.paradox.sbt.ParadoxPlugin
import com.lightbend.paradox.sbt.ParadoxPlugin.autoImport._
import com.lightbend.paradox.apidoc.ApidocPlugin
import DeployRsync.autoImport.deployRsyncArtifacts
import sbt.Keys._
import sbt._
@ -76,6 +77,8 @@ object Paradox {
name in (Compile, paradox) := "Akka",
resolvers += Resolver.jcenterRepo,
ApidocPlugin.autoImport.apidocRootPackage := "akka",
DeployRsync.autoImport.deployRsyncArtifact := List(
(Compile / paradox).value -> s"www/docs/akka/${version.value}"))
deployRsyncArtifacts += {
val releaseVersion = if (isSnapshot.value) "snapshot" else version.value
((Compile / paradox).value -> s"www/docs/akka/$releaseVersion")
})
}

View file

@ -69,17 +69,18 @@ object DeployRsync extends AutoPlugin {
override def requires = plugins.JvmPlugin
trait Keys {
val deployRsyncArtifact = taskKey[Seq[(File, String)]]("File or directory and a path to deploy to")
val deployRsync = inputKey[Unit]("Deploy using SCP")
val deployRsyncArtifacts = taskKey[Seq[(File, String)]]("File or directory and a path to deploy to")
val deployRsync = inputKey[Unit]("Deploy using rsync")
}
object autoImport extends Keys
import autoImport._
override def projectSettings =
Seq(deployRsync := {
override def projectSettings = Seq(
deployRsyncArtifacts := List(),
deployRsync := {
val (_, host) = (Space ~ StringBasic).parsed
deployRsyncArtifact.value.foreach {
deployRsyncArtifacts.value.foreach {
case (from, to) => s"rsync -rvz $from/ $host:$to" !
}
})

View file

@ -1,63 +0,0 @@
/*
* Copyright (C) 2016-2020 Lightbend Inc. <https://www.lightbend.com>
*/
package akka
import sbt._
import sbt.Keys._
import java.io.File
import com.jsuereth.sbtpgp.PgpKeys.publishSigned
import sbtunidoc.BaseUnidocPlugin.autoImport.unidoc
import com.lightbend.paradox.sbt.ParadoxKeys
object Release extends ParadoxKeys {
val releaseDirectory = SettingKey[File]("release-directory")
lazy val settings: Seq[Setting[_]] = commandSettings ++ Seq(releaseDirectory := target.value / "release")
lazy val commandSettings = Seq(commands ++= Seq(buildReleaseCommand, buildDocsCommand))
def buildReleaseCommand = Command.command("buildRelease") { state =>
val extracted = Project.extract(state)
val release = extracted.get(releaseDirectory)
val releaseVersion = extracted.get(version)
val projectRef = extracted.get(thisProjectRef)
val repo = extracted.get(Publish.defaultPublishTo)
val state1 = extracted.runAggregated(publishSigned in projectRef, state)
IO.delete(release)
IO.createDirectory(release)
IO.copyDirectory(repo, release / "releases")
state1
}
def buildDocsCommand = Command.command("buildDocs") { state =>
if (!sys.props.contains("akka.genjavadoc.enabled"))
throw new RuntimeException(
"Make sure you start sbt with \"-Dakka.genjavadoc.enabled=true\" otherwise no japi will be generated")
val extracted = Project.extract(state)
// we want to build the api-docs and docs with the current "default" version of scala
val scalaV = extracted.get(scalaVersion)
val expectedScalaV = extracted.get(crossScalaVersions).head
if (scalaV != expectedScalaV)
throw new RuntimeException(s"The docs should be built with Scala $expectedScalaV (was $scalaV)")
val release = extracted.get(releaseDirectory)
val releaseVersion = extracted.get(version)
val projectRef = extracted.get(thisProjectRef)
val (state2, Seq(japi, api)) = extracted.runTask(unidoc in Compile, state)
val (state3, docs) = extracted.runTask(paradox in ProjectRef(projectRef.build, "akka-docs") in Compile, state2)
IO.delete(release / "api")
IO.delete(release / "japi")
IO.delete(release / "docsapi")
IO.createDirectory(release)
IO.copyDirectory(api, release / "api" / "akka" / releaseVersion)
IO.copyDirectory(japi, release / "japi" / "akka" / releaseVersion)
IO.copyDirectory(docs, release / "docs" / "akka" / releaseVersion)
state3
}
}

View file

@ -89,7 +89,6 @@ declare -r default_server="akkarepo@gustav.akka.io"
declare -r default_path="www"
# settings
declare -r release_dir="target/release"
declare release_server=${default_server}
declare release_path=${default_path}
@ -279,14 +278,9 @@ else
fi
# Release artifacts
try sbt $RELEASE_OPT +buildRelease
try sbt $RELEASE_OPT +publishSigned
echolog "Successfully created released artifacts"
# Build the docs
try sbt $RELEASE_OPT buildDocs
echolog "Successfully created docs"
echolog "Successfully released artifacts"
try sbt $RELEASE_OPT whitesourceCheckPolicies
@ -325,19 +319,14 @@ else
important git push origin --tags
fi
# push the docs to the server
echolog "Pushing ${release_dir} docs to ${publish_path} ..."
echolog "Building docs and pushing to the server..."
if [ $dry_run ]; then
echodry "Not actually pushing to server. Commands:"
echodry " sbt $RELEASE_OPT deployRsync"
echodry " rsync -rlpvz --chmod=Dg+ws,Fg+w --exclude ${release_dir}/downloads --exclude ${release_dir}/docs ${release_dir}/ ${publish_path}/"
else
important ssh ${release_server} "cd ${release_path}/docs/akka; git add .; git commit -m 'before publishing version $version'; true"
# using Scala 2.13 here to avoid the infamous problem with missing AskSupport in classpath
important sbt -Dakka.build.scalaVersion=2.13.0 $RELEASE_OPT "deployRsync ${release_server}"
important rsync -rlpvz --chmod=Dg+ws,Fg+w --exclude downloads --exclude docs ${release_dir}/ ${publish_path}/
#important ssh ${release_server} cp -v ${release_path}/docs/akka/${version}/_static/warnOldDocs.js ${release_path}/docs/akka
#important ssh ${release_server} ln -snvf ../../warnOldDocs.js ${release_path}/docs/akka/${version}/_static/warnOldDocs.js
important ssh ${release_server} "cd ${release_path}/docs/akka; git add .; git commit -m 'publish version $version'"
fi