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:
parent
60ec32439c
commit
1a529aa38a
7 changed files with 33 additions and 90 deletions
|
|
@ -75,6 +75,7 @@ lazy val aggregatedProjects: Seq[ProjectReference] = List[ProjectReference](
|
||||||
|
|
||||||
lazy val root = Project(id = "akka", base = file("."))
|
lazy val root = Project(id = "akka", base = file("."))
|
||||||
.aggregate(aggregatedProjects: _*)
|
.aggregate(aggregatedProjects: _*)
|
||||||
|
.enablePlugins(DeployRsync)
|
||||||
.settings(rootSettings: _*)
|
.settings(rootSettings: _*)
|
||||||
.settings(unidocRootIgnoreProjects := Seq(remoteTests, benchJmh, protobuf, protobufV3, akkaScalaNightly, docs))
|
.settings(unidocRootIgnoreProjects := Seq(remoteTests, benchJmh, protobuf, protobufV3, akkaScalaNightly, docs))
|
||||||
.settings(unmanagedSources in (Compile, headerCreate) := (baseDirectory.value / "project").**("*.scala").get)
|
.settings(unmanagedSources in (Compile, headerCreate) := (baseDirectory.value / "project").**("*.scala").get)
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,6 @@ object AkkaBuild {
|
||||||
Dependencies.Versions)
|
Dependencies.Versions)
|
||||||
|
|
||||||
lazy val rootSettings = Def.settings(
|
lazy val rootSettings = Def.settings(
|
||||||
Release.settings,
|
|
||||||
UnidocRoot.akkaSettings,
|
UnidocRoot.akkaSettings,
|
||||||
Protobuf.settings,
|
Protobuf.settings,
|
||||||
parallelExecution in GlobalScope := System.getProperty("akka.parallelExecution", parallelExecutionByDefault.toString).toBoolean,
|
parallelExecution in GlobalScope := System.getProperty("akka.parallelExecution", parallelExecutionByDefault.toString).toBoolean,
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ import sbtunidoc.GenJavadocPlugin.autoImport._
|
||||||
import sbt.Keys._
|
import sbt.Keys._
|
||||||
import sbt.File
|
import sbt.File
|
||||||
import scala.annotation.tailrec
|
import scala.annotation.tailrec
|
||||||
|
import DeployRsync.autoImport.deployRsyncArtifacts
|
||||||
|
|
||||||
import sbt.ScopeFilter.ProjectFilter
|
import sbt.ScopeFilter.ProjectFilter
|
||||||
|
|
||||||
|
|
@ -23,7 +24,7 @@ object Scaladoc extends AutoPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
override def trigger = allRequirements
|
override def trigger = allRequirements
|
||||||
override def requires = plugins.JvmPlugin
|
override def requires = plugins.JvmPlugin && DeployRsync
|
||||||
|
|
||||||
val validateDiagrams = settingKey[Boolean]("Validate generated scaladoc diagrams")
|
val validateDiagrams = settingKey[Boolean]("Validate generated scaladoc diagrams")
|
||||||
|
|
||||||
|
|
@ -132,10 +133,22 @@ object UnidocRoot extends AutoPlugin {
|
||||||
.getOrElse(sbtunidoc.ScalaUnidocPlugin)
|
.getOrElse(sbtunidoc.ScalaUnidocPlugin)
|
||||||
|
|
||||||
val akkaSettings = UnidocRoot.CliOptions.genjavadocEnabled
|
val akkaSettings = UnidocRoot.CliOptions.genjavadocEnabled
|
||||||
.ifTrue(Seq(javacOptions in (JavaUnidoc, unidoc) := {
|
.ifTrue(Seq(
|
||||||
if (JdkOptions.isJdk8) Seq("-Xdoclint:none")
|
javacOptions in (JavaUnidoc, unidoc) := {
|
||||||
else Seq("-Xdoclint:none", "--ignore-source-errors", "--no-module-directories")
|
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)
|
.getOrElse(Nil)
|
||||||
|
|
||||||
override lazy val projectSettings = {
|
override lazy val projectSettings = {
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ package akka
|
||||||
import com.lightbend.paradox.sbt.ParadoxPlugin
|
import com.lightbend.paradox.sbt.ParadoxPlugin
|
||||||
import com.lightbend.paradox.sbt.ParadoxPlugin.autoImport._
|
import com.lightbend.paradox.sbt.ParadoxPlugin.autoImport._
|
||||||
import com.lightbend.paradox.apidoc.ApidocPlugin
|
import com.lightbend.paradox.apidoc.ApidocPlugin
|
||||||
|
import DeployRsync.autoImport.deployRsyncArtifacts
|
||||||
import sbt.Keys._
|
import sbt.Keys._
|
||||||
import sbt._
|
import sbt._
|
||||||
|
|
||||||
|
|
@ -76,6 +77,8 @@ object Paradox {
|
||||||
name in (Compile, paradox) := "Akka",
|
name in (Compile, paradox) := "Akka",
|
||||||
resolvers += Resolver.jcenterRepo,
|
resolvers += Resolver.jcenterRepo,
|
||||||
ApidocPlugin.autoImport.apidocRootPackage := "akka",
|
ApidocPlugin.autoImport.apidocRootPackage := "akka",
|
||||||
DeployRsync.autoImport.deployRsyncArtifact := List(
|
deployRsyncArtifacts += {
|
||||||
(Compile / paradox).value -> s"www/docs/akka/${version.value}"))
|
val releaseVersion = if (isSnapshot.value) "snapshot" else version.value
|
||||||
|
((Compile / paradox).value -> s"www/docs/akka/$releaseVersion")
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -69,17 +69,18 @@ object DeployRsync extends AutoPlugin {
|
||||||
override def requires = plugins.JvmPlugin
|
override def requires = plugins.JvmPlugin
|
||||||
|
|
||||||
trait Keys {
|
trait Keys {
|
||||||
val deployRsyncArtifact = taskKey[Seq[(File, String)]]("File or directory and a path to deploy to")
|
val deployRsyncArtifacts = taskKey[Seq[(File, String)]]("File or directory and a path to deploy to")
|
||||||
val deployRsync = inputKey[Unit]("Deploy using SCP")
|
val deployRsync = inputKey[Unit]("Deploy using rsync")
|
||||||
}
|
}
|
||||||
|
|
||||||
object autoImport extends Keys
|
object autoImport extends Keys
|
||||||
import autoImport._
|
import autoImport._
|
||||||
|
|
||||||
override def projectSettings =
|
override def projectSettings = Seq(
|
||||||
Seq(deployRsync := {
|
deployRsyncArtifacts := List(),
|
||||||
|
deployRsync := {
|
||||||
val (_, host) = (Space ~ StringBasic).parsed
|
val (_, host) = (Space ~ StringBasic).parsed
|
||||||
deployRsyncArtifact.value.foreach {
|
deployRsyncArtifacts.value.foreach {
|
||||||
case (from, to) => s"rsync -rvz $from/ $host:$to" !
|
case (from, to) => s"rsync -rvz $from/ $host:$to" !
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -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
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -89,7 +89,6 @@ declare -r default_server="akkarepo@gustav.akka.io"
|
||||||
declare -r default_path="www"
|
declare -r default_path="www"
|
||||||
|
|
||||||
# settings
|
# settings
|
||||||
declare -r release_dir="target/release"
|
|
||||||
declare release_server=${default_server}
|
declare release_server=${default_server}
|
||||||
declare release_path=${default_path}
|
declare release_path=${default_path}
|
||||||
|
|
||||||
|
|
@ -279,14 +278,9 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Release artifacts
|
# Release artifacts
|
||||||
try sbt $RELEASE_OPT +buildRelease
|
try sbt $RELEASE_OPT +publishSigned
|
||||||
|
|
||||||
echolog "Successfully created released artifacts"
|
echolog "Successfully released artifacts"
|
||||||
|
|
||||||
# Build the docs
|
|
||||||
try sbt $RELEASE_OPT buildDocs
|
|
||||||
|
|
||||||
echolog "Successfully created docs"
|
|
||||||
|
|
||||||
try sbt $RELEASE_OPT whitesourceCheckPolicies
|
try sbt $RELEASE_OPT whitesourceCheckPolicies
|
||||||
|
|
||||||
|
|
@ -325,19 +319,14 @@ else
|
||||||
important git push origin --tags
|
important git push origin --tags
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# push the docs to the server
|
echolog "Building docs and pushing to the server..."
|
||||||
echolog "Pushing ${release_dir} docs to ${publish_path} ..."
|
|
||||||
if [ $dry_run ]; then
|
if [ $dry_run ]; then
|
||||||
echodry "Not actually pushing to server. Commands:"
|
echodry "Not actually pushing to server. Commands:"
|
||||||
echodry " sbt $RELEASE_OPT deployRsync"
|
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
|
else
|
||||||
important ssh ${release_server} "cd ${release_path}/docs/akka; git add .; git commit -m 'before publishing version $version'; true"
|
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
|
# 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 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'"
|
important ssh ${release_server} "cd ${release_path}/docs/akka; git add .; git commit -m 'publish version $version'"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue