Skip to content

Commit

Permalink
Docs: more settings to improve the generated site (#579)
Browse files Browse the repository at this point in the history
* Docs: more settings to improve the generated site

* Move settings to Common auto-plugin

* No CrossVersion.binary
  • Loading branch information
ennru authored and raboof committed May 23, 2019
1 parent 5de6e0b commit 2af116c
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 48 deletions.
38 changes: 9 additions & 29 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,6 @@ import akka.grpc.build.ReflectiveCodeGen

scalaVersion := scala212

val commonSettings = Seq(
organization := "com.lightbend.akka.grpc",
scalacOptions ++= List(
"-unchecked",
"-deprecation",
"-language:_",
"-encoding", "UTF-8"
),
javacOptions ++= List(
"-Xlint:unchecked",
"-Xlint:deprecation"
)
) ++ akka.grpc.Formatting.formatSettings

val akkaGrpcRuntimeName = "akka-grpc-runtime"

lazy val codegen = Project(
Expand All @@ -27,7 +13,6 @@ lazy val codegen = Project(
)
.enablePlugins(SbtTwirl, BuildInfoPlugin)
.settings(Dependencies.codegen)
.settings(commonSettings)
.settings(Seq(
buildInfoKeys ++= BuildInfoKey.ofN(organization, name, version, scalaVersion, sbtVersion),
buildInfoKeys += "runtimeArtifactName" -> akkaGrpcRuntimeName,
Expand All @@ -51,7 +36,6 @@ lazy val runtime = Project(
base = file("runtime")
)
.settings(Dependencies.runtime)
.settings(commonSettings)

/** This could be an independent project - or does upstream provide this already? didn't find it.. */
lazy val scalapbProtocPlugin = Project(
Expand All @@ -60,7 +44,6 @@ lazy val scalapbProtocPlugin = Project(
)
/** TODO we only really need to depend on scalapb */
.dependsOn(codegen)
.settings(commonSettings)
.settings(Seq(
artifact in (Compile, assembly) := {
val art = (artifact in (Compile, assembly)).value
Expand All @@ -77,7 +60,6 @@ lazy val mavenPlugin = Project(
id = "akka-grpc-maven-plugin",
base = file("maven-plugin")
)
.settings(commonSettings)
.settings(Dependencies.mavenPlugin)
.enablePlugins(akka.grpc.SbtMavenPlugin)
.settings(Seq(
Expand All @@ -90,7 +72,6 @@ lazy val sbtPlugin = Project(
id = "sbt-akka-grpc",
base = file("sbt-plugin")
)
.settings(commonSettings)
.settings(Dependencies.sbtPlugin)
.enablePlugins(SbtPlugin)
.settings(
Expand All @@ -117,7 +98,6 @@ lazy val interopTests = Project(
base = file("interop-tests")
)
.settings(Dependencies.interopTests)
.settings(commonSettings)
.pluginTestingSettings
.settings(
ReflectiveCodeGen.generatedLanguages := Seq("Scala", "Java"),
Expand Down Expand Up @@ -156,16 +136,18 @@ lazy val docs = Project(
.dependsOn(pluginTesterScala)
.dependsOn(pluginTesterJava)
.enablePlugins(AkkaParadoxPlugin)
.enablePlugins(akka.grpc.NoPublish)
.settings(
skip in publish := true,
// Make sure code generation is ran before paradox:
(Compile / paradox) := ((Compile / paradox) dependsOn (Compile / compile)).value,
paradoxGroups := Map(
"Language" -> Seq("Scala", "Java"),
Compile / paradoxGroups := Map(
"Language" -> Seq("Java", "Scala"),
"Buildtool" -> Seq("sbt", "Gradle", "Maven"),
),
paradoxProperties ++= Map(
Compile / paradoxProperties ++= Map(
"grpc.version" Dependencies.Versions.grpc,
"project.url" -> "https://developer.lightbend.com/docs/akka-grpc/current/",
"canonical.base_url" -> "https://developer.lightbend.com/docs/akka-grpc/current/",
"akka-http.version" Dependencies.Versions.akkaHttp,
"extref.akka-http.base_url" -> s"https://doc.akka.io/docs/akka-http/${Dependencies.Versions.akkaHttp}/%s",
),
Expand All @@ -177,9 +159,8 @@ lazy val pluginTesterScala = Project(
base = file("plugin-tester-scala")
)
.settings(Dependencies.pluginTester)
.settings(commonSettings)
.enablePlugins(akka.grpc.NoPublish)
.settings(
skip in publish := true,
ReflectiveCodeGen.codeGeneratorSettings ++= Seq("flat_package", "server_power_apis")
)
.pluginTestingSettings
Expand All @@ -189,9 +170,8 @@ lazy val pluginTesterJava = Project(
base = file("plugin-tester-java")
)
.settings(Dependencies.pluginTester)
.settings(commonSettings)
.enablePlugins(akka.grpc.NoPublish)
.settings(
skip in publish := true,
ReflectiveCodeGen.generatedLanguages := Seq("Java"),
ReflectiveCodeGen.codeGeneratorSettings ++= Seq("server_power_apis")
)
Expand All @@ -213,7 +193,7 @@ lazy val root = Project(
pluginTesterJava,
docs,
)
.enablePlugins(akka.grpc.NoPublish)
.settings(
skip in publish := true,
unmanagedSources in (Compile, headerCreate) := (baseDirectory.value / "project").**("*.scala").get
)
4 changes: 4 additions & 0 deletions docs/src/main/paradox/_template/projectSpecificFooter.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<script type="text/javascript" src="$page.base$assets/js/warnOldVersion.js"></script>
<script type="text/javascript">//<![CDATA[
jQuery(function(jq){initOldVersionWarnings(jq, '$page.properties.("project.version")$', '$page.properties.("project.url")$')});
//]]></script>
23 changes: 23 additions & 0 deletions docs/src/main/paradox/assets/js/warnOldVersion.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
function initOldVersionWarnings($, thisVersion, projectUrl) {
if (projectUrl && projectUrl !== "") {
var schemeLessUrl = projectUrl;
if (projectUrl.startsWith("http://")) projectUrl = schemeLessUrl.substring(5);
else if (projectUrl.startsWith("https://")) projectUrl = schemeLessUrl.substring(6);
const url = schemeLessUrl + (schemeLessUrl.endsWith("\/") ? "" : "/") + "paradox.json";
$.get(url, function (versionData) {
const currentVersion = versionData.version;
if (thisVersion !== currentVersion) {
showVersionWarning(thisVersion, currentVersion, projectUrl);
}
});
}
}

function showVersionWarning(thisVersion, currentVersion, projectUrl) {
$('#docs').prepend(
'<div class="callout warning" style="margin-top: 16px">' +
'<p><span style="font-weight: bold">This documentation regards version ' + thisVersion + ', ' +
'however the current version is <a href="' + projectUrl + '">' + currentVersion + '</a>.</span></p>' +
'</div>'
);
}
38 changes: 38 additions & 0 deletions project/Common.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import sbt.Keys._
import sbt._
import sbt.plugins.JvmPlugin

object Common extends AutoPlugin {

override def trigger = allRequirements

override def requires = JvmPlugin

override def globalSettings = Seq(
organization := "com.lightbend.akka.grpc",
organizationName := "Lightbend Inc.",
organizationHomepage := Some(url("https://www.lightbend.com/")),
// apiURL := Some(url(s"https://doc.akka.io/api/akka-grpc/${version.value}")),
homepage := Some(url("https://akka.io/")),
scmInfo := Some(ScmInfo(url("https://github.com/akka/akka-grpc"), "git@github.com:akka/akka-grpc")),
developers += Developer("contributors",
"Contributors",
"https://gitter.im/akka/dev",
url("https://github.com/akka/akka-grpc/graphs/contributors")),
licenses := Seq("Apache-2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0")),
description := "Akka gRPC - Support for building streaming gRPC servers and clients on top of Akka Streams."
)

override lazy val projectSettings = Seq(
scalacOptions ++= List(
"-unchecked",
"-deprecation",
"-language:_",
"-encoding", "UTF-8"
),
javacOptions ++= List(
"-Xlint:unchecked",
"-Xlint:deprecation"
)
) ++ akka.grpc.Formatting.formatSettings
}
18 changes: 0 additions & 18 deletions project/Publish.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,6 @@ package akka.grpc

import sbt._, Keys._

/**
* For projects that are not to be published.
*/
object NoPublish extends AutoPlugin {
override def requires = plugins.JvmPlugin

override def projectSettings = Seq(
skip in publish := true,
)
}

object Publish extends AutoPlugin {
import bintray.BintrayPlugin
import bintray.BintrayPlugin.autoImport._
Expand All @@ -23,13 +12,6 @@ object Publish extends AutoPlugin {
override def projectSettings = Seq(
bintrayOrganization := Some("akka"),
bintrayPackage := "akka-grpc",
homepage := Some(url("https://developer.lightbend.com/docs/akka-grpc/current/")),
scmInfo := Some(ScmInfo(url("https://github.com/akka/akka-grpc"), "git@github.com:akka/akka-grpc")),
licenses := Seq("Apache-2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0")),
developers += Developer("contributors",
"Contributors",
"https://gitter.im/akka/dev",
url("https://github.com/akka/akka-grpc/graphs/contributors")),
)
}

Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ object GrpcResponseHelpers {
entity = HttpEntity.Chunked(Grpc.contentType, outChunks))
}

def status(status: Status): HttpResponse =
def status(status: Status): HttpResponse =
HttpResponse(entity = HttpEntity.Chunked(Grpc.contentType, Source.single(trailer(status))))

def trailer(status: Status): LastChunk =
Expand Down

0 comments on commit 2af116c

Please # to comment.