From 65e4ed2c1e57669f69cbae9db3e435f8f75b2b6a Mon Sep 17 00:00:00 2001 From: Ignasi Marimon-Clos Date: Thu, 28 Feb 2019 18:12:17 +0100 Subject: [PATCH] Fixes application of javac options (#18) This PR fixes the syntax to enable `javacOptions` in each of the `sbt` modules. This fix revealed a deprecation warning in akka-grpc generated code. The consequence of this warning with the `-Werror` flag is the build of this PR will break. Unfortunately the newet `0.5.0` release of `akka-grpc` introduces other compilation errors on the generated code so at the moment we can't have a 100% error-free lagom-grpc sample. --- build.sbt | 24 ++++++++++--------- .../hello/impl/HelloGrpcServiceImpl.java | 5 ++-- project/plugins.sbt | 7 ++++-- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/build.sbt b/build.sbt index 8ea2c7d5..02e52038 100644 --- a/build.sbt +++ b/build.sbt @@ -12,18 +12,13 @@ scalaVersion in ThisBuild := "2.12.8" lagomServiceEnableSsl in ThisBuild := true val `hello-impl-HTTPS-port` = 11000 - -// ALL SETTINGS HERE ARE TEMPORARY WORKAROUNDS FOR KNOWN ISSUES OR WIP -def workaroundSettings: Seq[sbt.Setting[_]] = Seq( - // Lagom still can't register a service under the gRPC name so we hard-code t - // he port and the use the value to add the entry on the Service Registry - lagomServiceHttpsPort := `hello-impl-HTTPS-port` -) +resolvers in ThisBuild += Resolver.bintrayRepo("akka", "maven") // for snapshot akka-grpc lazy val `lagom-java-grpc-example` = (project in file(".")) .aggregate(`hello-api`, `hello-impl`, `hello-proxy-api`, `hello-proxy-impl`) lazy val `hello-api` = (project in file("hello-api")) + .settings(common) .settings( libraryDependencies ++= Seq( lagomJavadslApi @@ -34,6 +29,7 @@ lazy val `hello-impl` = (project in file("hello-impl")) .enablePlugins(LagomJava) .enablePlugins(AkkaGrpcPlugin) // enables source generation for gRPC .enablePlugins(PlayAkkaHttp2Support) // enables serving HTTP/2 and gRPC + .settings(common) .settings( akkaGrpcGeneratedLanguages := Seq(AkkaGrpc.Java), akkaGrpcGeneratedSources := @@ -42,9 +38,11 @@ lazy val `hello-impl` = (project in file("hello-impl")) AkkaGrpc.Client // the client is only used in tests. See https://github.com/akka/akka-grpc/issues/410 ), akkaGrpcExtraGenerators in Compile += PlayJavaServerCodeGenerator, -).settings( - workaroundSettings: _* -).settings( + + // WORKAROUND: Lagom still can't register a service under the gRPC name so we hard-code + // the port and the use the value to add the entry on the Service Registry + lagomServiceHttpsPort := `hello-impl-HTTPS-port`, + libraryDependencies ++= Seq( lagomJavadslTestKit, lagomLogback @@ -53,6 +51,7 @@ lazy val `hello-impl` = (project in file("hello-impl")) .dependsOn(`hello-api`) lazy val `hello-proxy-api` = (project in file("hello-proxy-api")) + .settings(common) .settings( libraryDependencies ++= Seq( lagomJavadslApi @@ -62,6 +61,7 @@ lazy val `hello-proxy-api` = (project in file("hello-proxy-api")) lazy val `hello-proxy-impl` = (project in file("hello-proxy-impl")) .enablePlugins(LagomJava) .enablePlugins(AkkaGrpcPlugin) // enables source generation for gRPC + .settings(common) .settings( akkaGrpcGeneratedLanguages := Seq(AkkaGrpc.Java), akkaGrpcExtraGenerators += PlayJavaClientCodeGenerator, @@ -84,4 +84,6 @@ lagomKafkaEnabled in ThisBuild := false lagomUnmanagedServices in ThisBuild := Map("helloworld.GreeterService" -> s"https://localhost:${`hello-impl-HTTPS-port`}") -ThisBuild / javacOptions ++= List("-Xlint:unchecked", "-Xlint:deprecation", "-Werror") \ No newline at end of file +def common = Seq( + javacOptions in Compile ++= Seq("-Xlint:unchecked", "-Xlint:deprecation", "-parameters", "-Werror") +) diff --git a/hello-impl/src/main/java/com/example/hello/impl/HelloGrpcServiceImpl.java b/hello-impl/src/main/java/com/example/hello/impl/HelloGrpcServiceImpl.java index 202fad4e..c7215885 100644 --- a/hello-impl/src/main/java/com/example/hello/impl/HelloGrpcServiceImpl.java +++ b/hello-impl/src/main/java/com/example/hello/impl/HelloGrpcServiceImpl.java @@ -1,5 +1,6 @@ package com.example.hello.impl; +import akka.actor.ActorSystem; import akka.stream.Materializer; import example.myapp.helloworld.grpc.AbstractGreeterServiceRouter; import example.myapp.helloworld.grpc.HelloReply; @@ -14,8 +15,8 @@ public class HelloGrpcServiceImpl extends AbstractGreeterServiceRouter { @Inject - public HelloGrpcServiceImpl(Materializer mat) { - super(mat); + public HelloGrpcServiceImpl(ActorSystem sys, Materializer mat) { + super(mat, sys); } @Override diff --git a/project/plugins.sbt b/project/plugins.sbt index da874dca..fb152594 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -2,8 +2,11 @@ addSbtPlugin("com.lightbend.lagom" % "lagom-sbt-plugin" % "1.5.0-RC2") // Akka GRPC -addSbtPlugin("com.lightbend.akka.grpc" %% "sbt-akka-grpc" % "0.4.2") - +addSbtPlugin("com.lightbend.akka.grpc" %% "sbt-akka-grpc" % "0.5.0+14-c97a24a0") +resolvers ++= Seq( // for the snapshot ^ + Resolver.bintrayIvyRepo("akka", "sbt-plugin-releases"), + Resolver.bintrayRepo("akka", "maven"), +) // Needed for importing the project into Eclipse addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.2.4")