New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP][Proposal] LagomPlayServiceScala
plugin
#1509
[WIP][Proposal] LagomPlayServiceScala
plugin
#1509
Conversation
…yService` and the `LagomPlay` plugins are enabled, not when the `PlayScala` and the `LagomPlay` are enabled.
LagomPlayScala
plugin should be automatically enabled when the `Pla…LagomPlayServiceScala
plugin
LagomPlayServiceScala
pluginLagomPlayServiceScala
plugin
@guizmaii could you add a little more context about what this pull request is for? |
Hi @TimMoore The goal of this pull request is to propose a new Lagom plugin that will permit Lagom users to develop "PlayScala" apps with the minimal More info on this layout: https://www.playframework.com/documentation/2.6.x/Highlights26#PlayService-sbt-plugin-(experimental) Why is this interesting ?We're using ReactJS to develop the web part of our app. So we don't need Twirl and co. This app is just used to serve the JS/CSS/HTML files. final class FrontEndRouter(
env: Environment,
assets: Assets,
action: DefaultActionBuilder
) extends SimpleRouter {
private lazy val npmHost = "http://localhost:3000"
private def devRoutes: Router.Routes = {
case GET(p"/") =>
action {
TemporaryRedirect(npmHost)
}
}
private def prodRoutes: Router.Routes = {
case GET(p"/frontend/health") => action.apply(Ok("Hello World"))
case GET(p"/static/$file*") => assets.versioned(path = "/public/static", file = file)
case GET(p"/*") => assets.versioned(path = "/public", file = "index.html")
case GET(p"/") => assets.versioned(path = "/public", file = "index.html")
}
override val routes: Router.Routes = if (env.mode == Mode.Dev) devRoutes else prodRoutes
} Why do we need a new Lagom plugin ?Because for now if you want to use the import com.lightbend.lagom.sbt.{LagomImport, LagomReloadableService}
import play.sbt.PlayImport.PlayKeys
import play.sbt.PlayInternalKeys
import sbt.Keys.libraryDependencies
/**
*
* This is all the configurations automatically added by this `LagomPlayScala` plugin.
* So it's equivalent to a reimplementation of the `LagomPlayScala` plugin.
*
* More info:
* - https://github.com/lagom/lagom/blob/master/dev/sbt-plugin/src/main/scala/com/lightbend/lagom/sbt/LagomPlugin.scala#L112
* - https://github.com/lagom/lagom/blob/master/dev/sbt-plugin/src/main/scala/com/lightbend/lagom/sbt/LagomPlugin.scala#L154
*/
object CustomLagomPlayScala {
import LagomReloadableService.autoImport._
val projectSettings = Seq(
// Run the Play reload task when Lagom requests a reload
lagomReload := PlayInternalKeys.playReload.value,
// Play wants to add the assets classloader to the application classloader
lagomClassLoaderDecorator := PlayInternalKeys.playAssetsClassLoader.value,
// Watch the files that Play wants to watch
lagomWatchDirectories := PlayKeys.playMonitoredFiles.value,
libraryDependencies += LagomImport.lagomScaladslDevMode
)
} lazy val frontEnd: Project = Project(id = "frontEnd")
.enablePlugins(LagomPlugin, PlayService, LagomReloadableService, SbtWeb)
.settings(CustomLagomPlayScala.projectSettings: _*) With the new plugin, all the above code would only be: lazy val frontEnd: Project = Project(id = "frontEnd")
.enablePlugins(LagomPlayServiceScala, SbtWeb) |
I might be missing some context, but do you think it would be possible to just amend the existing |
Hi @erip, It's not possible to just edit the current Plus, it's a new feature that Lagom offers to its users, not a modification of a current feature. Did I answer your questions correctly ? |
Pull Request Checklist
Fixes
Fixes #xxxx
Purpose
I recently discovered the
PlayService
plugins.Could be great to help people to use it in their Lagom app.
Background Context
Why did you take this approach?
References
Are there any relevant issues / PRs / mailing lists discussions?