diff --git a/README.md b/README.md index bf55dcc136f..84079ed179a 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ The documentation is generated from the lagom main project as unstyled HTML snip ## Developing the website -A static version of the website can be generated by running `sbt web-stage`. This will output the entire website to the `target/web/stage` directory. You should start a simple HTTP server from here to serve the docs, eg using `python -m SimpleHTTPServer`. The `sbt ~web-stage` command can be used to tell sbt to watch for changes and rebuild the site whenever anything changes. +A static version of the website can be generated by running `sbt webStage`. This will output the entire website to the `target/web/stage` directory. You should start a simple HTTP server from here to serve the docs, eg using `python -m SimpleHTTPServer`. The `sbt ~web-stage` command can be used to tell sbt to watch for changes and rebuild the site whenever anything changes. For convenience, `sbt run` does the above for you, starting a static Akka HTTP server in the stage directory, and then watching the filesystem for changes and rebuilding the site whenever it changes. diff --git a/build.sbt b/build.sbt index a86ad3f2766..c20255c51ed 100644 --- a/build.sbt +++ b/build.sbt @@ -1,4 +1,6 @@ +import scala.sys.process._ import java.io.Closeable +import sbt.PathFinder import scala.concurrent.Await @@ -61,8 +63,8 @@ val runCommand = Command.make("run") { state => javaOptions += "-Ddev", fork := true // required for javaOptions to take effect ) - val stateWithExtraSettings = extracted.append(extraSettings, stateWithStop) - Parser.parse("~web-stage", stateWithExtraSettings.combinedParser) match { + val stateWithExtraSettings = extracted.appendWithSession(extraSettings, stateWithStop) + Parser.parse("~webStage", stateWithExtraSettings.combinedParser) match { case Right(cmd) => cmd() case Left(msg) => throw sys.error(s"Invalid command:\n$msg") } @@ -74,7 +76,7 @@ commands ++= Seq(runCommand, stopCommand) val generateHtml = taskKey[Seq[File]]("Generate the site HTML") target in generateHtml := WebKeys.webTarget.value / "generated-html" -generateHtml <<= Def.taskDyn { +generateHtml := Def.taskDyn { val outputDir = (target in generateHtml).value val docsDir = sourceDirectory.value / "docs" val markdownDir = (sourceDirectory in Compile).value / "markdown" @@ -88,9 +90,9 @@ generateHtml <<= Def.taskDyn { blogDir, assetFingerPrint ).mkString(" ", " ", "")).value - outputDir.***.filter(_.isFile).get + outputDir.allPaths.filter(_.isFile).get } -} +}.value def path(segments: String*): String = segments.mkString(java.io.File.separator) @@ -115,11 +117,14 @@ StylusKeys.compress := true pipelineStages := Seq(uglify, concat) WebKeys.pipeline ++= { - generateHtml.value pair relativeTo((target in generateHtml).value) + generateHtml.value pair Path.relativeTo((target in generateHtml).value) } watchSources ++= { - ((sourceDirectory in Compile).value / "markdown").***.get ++ - (sourceDirectory.value / "blog").***.get + val markdownFolder: File = (sourceDirectory in Compile).value / "markdown" + val blogFolder: File = sourceDirectory.value / "blog" + val markdown: Seq[File] = markdownFolder.allPaths.get + val blog: Seq[File] = blogFolder.allPaths.get + markdown ++ blog } // Include hidden files in the output (e.g., src/main/public/.well-known) diff --git a/project/SimpleHTTPServer.scala b/project/SimpleHTTPServer.scala index 8e831917dcb..b76cdbfaf11 100644 --- a/project/SimpleHTTPServer.scala +++ b/project/SimpleHTTPServer.scala @@ -1,6 +1,6 @@ import java.io.{ Closeable, File } -import akka.actor.ActorSystem +import akka.actor.{ ActorSystem, CoordinatedShutdown } import akka.http.scaladsl.Http import akka.http.scaladsl.Http.ServerBinding import akka.http.scaladsl.server.Directives._ @@ -21,25 +21,25 @@ class SimpleHTTPServer(webDirectory: File, port: Int) extends Closeable { // needed for the future flatMap/onComplete in the end private implicit val executionContext = system.dispatcher - private val route404 = getFromFile(new File(webDirectory, "404.html")) - .andThen(_.map { - case Complete(response) => Complete(response.copy(status = 404)) - case other => other - }) + private val route404 = getFromFile(new File(webDirectory, "404.html")) + .andThen(_.map { + case Complete(response) => Complete(response.copy(status = 404)) + case other => other + }) - private val route = - getFromDirectory(webDirectory.getAbsolutePath) ~ - pathPrefix(Segments) { folderNameSeq => - val absoluteFolder = folderNameSeq.foldLeft(webDirectory)((acc, subfolder) => new File(acc, subfolder)) - getFromFile(new File(absoluteFolder, "index.html")) - } ~ route404 + private val route = + getFromDirectory(webDirectory.getAbsolutePath) ~ + pathPrefix(Segments) { folderNameSeq => + val absoluteFolder = folderNameSeq.foldLeft(webDirectory)((acc, subfolder) => new File(acc, subfolder)) + getFromFile(new File(absoluteFolder, "index.html")) + } ~ route404 - val bindingFuture: Future[ServerBinding] = Http().bindAndHandle(route, "localhost", port) + val bindingFuture: Future[ServerBinding] = Http().bindAndHandle(route, "localhost", port) def close(): Unit = { bindingFuture .flatMap(_.unbind()) - .onComplete(_ => system.shutdown()) + .onComplete(_ => CoordinatedShutdown(system).run(CoordinatedShutdown.JvmExitReason)) } } diff --git a/project/build.properties b/project/build.properties index 133a8f197e3..c0bab04941d 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=0.13.17 +sbt.version=1.2.8 diff --git a/project/plugins.sbt b/project/plugins.sbt index b9181f7cc62..d5639bed7a6 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,11 +1,12 @@ -addSbtPlugin("com.typesafe.sbt" % "sbt-twirl" % "1.1.1") -addSbtPlugin("com.typesafe.sbt" % "sbt-web" % "1.3.0") -addSbtPlugin("com.typesafe.sbt" % "sbt-js-engine" % "1.1.3") -addSbtPlugin("com.typesafe.sbt" % "sbt-stylus" % "1.0.1") -addSbtPlugin("net.ground5hark.sbt" % "sbt-concat" % "0.1.8") -addSbtPlugin("com.typesafe.sbt" % "sbt-uglify" % "1.0.3") +addSbtPlugin("com.typesafe.sbt" % "sbt-twirl" % "1.4.0") +addSbtPlugin("com.typesafe.sbt" % "sbt-web" % "1.4.4") +addSbtPlugin("com.typesafe.sbt" % "sbt-js-engine" % "1.2.3") +addSbtPlugin("com.typesafe.sbt" % "sbt-stylus" % "1.1.0") +addSbtPlugin("net.ground5hark.sbt" % "sbt-concat" % "0.2.0") +addSbtPlugin("com.typesafe.sbt" % "sbt-uglify" % "2.0.0") resolvers += "Typesafe Releases Repository" at "http://repo.typesafe.com/typesafe/releases/" // Used for our SimpleHTTPServer in Akka HTTP -libraryDependencies += "com.typesafe.akka" % "akka-http-experimental_2.10" % "2.0.4" +libraryDependencies += "com.typesafe.akka" %% "akka-http" % "10.1.8" +libraryDependencies += "com.typesafe.akka" %% "akka-stream" % "2.5.21" diff --git a/src/main/twirl/com/lightbend/lagom/docs/blogPost.scala.html b/src/main/twirl/com/lightbend/lagom/docs/blogPost.scala.html index 90fd40da626..be67ba5d3e0 100644 --- a/src/main/twirl/com/lightbend/lagom/docs/blogPost.scala.html +++ b/src/main/twirl/com/lightbend/lagom/docs/blogPost.scala.html @@ -1,3 +1,4 @@ +@import play.twirl.api._ @import com.lightbend.lagom.docs.BlogPost @import com.lightbend.lagom.docs.LagomContext diff --git a/src/main/twirl/com/lightbend/lagom/docs/main.scala.html b/src/main/twirl/com/lightbend/lagom/docs/main.scala.html index e52469d99ae..d789b43f625 100644 --- a/src/main/twirl/com/lightbend/lagom/docs/main.scala.html +++ b/src/main/twirl/com/lightbend/lagom/docs/main.scala.html @@ -1,3 +1,4 @@ +@import play.twirl.api._ @import com.lightbend.lagom.docs.svg.html._ @import com.lightbend.lagom.docs.LagomContext