Skip to content

Commit

Permalink
Fixes application of javac options (lagom#18)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ignasi35 authored and dwijnand committed Feb 28, 2019
1 parent 8ef2a27 commit 65e4ed2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
24 changes: 13 additions & 11 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 :=
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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,
Expand All @@ -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")
def common = Seq(
javacOptions in Compile ++= Seq("-Xlint:unchecked", "-Xlint:deprecation", "-parameters", "-Werror")
)
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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
Expand Down
7 changes: 5 additions & 2 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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")

0 comments on commit 65e4ed2

Please sign in to comment.