This is an automated email from the ASF dual-hosted git repository.

pjfanning pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pekko-grpc.git


The following commit(s) were added to refs/heads/main by this push:
     new 6eecbfdc correct config for sbt-java-formatter 0.12.0 (#685)
6eecbfdc is described below

commit 6eecbfdc0a64349cf216ba4a8ca2c9759a9ab63c
Author: Matthias Kurz <[email protected]>
AuthorDate: Tue Apr 21 22:01:24 2026 +0200

    correct config for sbt-java-formatter 0.12.0 (#685)
    
    * javafmtFormatterCompatibleJavaVersion := 17 / javafmtSortImports := false
    
    * javafmtAll
---
 build.sbt                                          |   5 +
 .../grpc/ExceptionGreeterServiceImpl.java          |  92 +++++++++--------
 .../pekko/grpc/interop/JavaTestServiceImpl.java    | 115 +++++++++++----------
 .../main/java/example/myapp/CombinedServer.java    |  56 +++++-----
 4 files changed, 140 insertions(+), 128 deletions(-)

diff --git a/build.sbt b/build.sbt
index 8f4c304c..647fb427 100644
--- a/build.sbt
+++ b/build.sbt
@@ -8,6 +8,7 @@
  */
 
 import com.github.pjfanning.pekkobuild._
+import com.github.sbt.JavaFormatterPlugin.autoImport.javafmtSortImports
 import 
net.bzzt.reproduciblebuilds.ReproducibleBuildsPlugin.reproducibleBuildsCheckResolver
 import org.apache.pekko.grpc.{ Dependencies, NoPublish, PekkoCoreDependency, 
PekkoHttpDependency }
 import org.apache.pekko.grpc.Dependencies.Versions.{ scala212, scala213 }
@@ -41,6 +42,8 @@ lazy val mkBatAssemblyTask = taskKey[File]("Create a Windows 
bat assembly")
 // gradle plugin compatibility (avoid `+` in snapshot versions)
 (ThisBuild / dynverSeparator) := "-"
 
+ThisBuild / javafmtFormatterCompatibleJavaVersion := 17
+
 val pekkoGrpcCodegenId = s"$pekkoPrefix-codegen"
 lazy val codegen = Project(id = "codegen", base = file("codegen"))
   .enablePlugins(SbtTwirl, BuildInfoPlugin)
@@ -194,6 +197,7 @@ lazy val interopTests = Project(id = "interop-tests", base 
= file("interop-tests
   .pluginTestingSettings
   .settings(
     name := s"$pekkoPrefix-interop-tests",
+    javafmtSortImports := false,
     // All io.grpc servers want to bind to port :8080
     parallelExecution := false,
     ReflectiveCodeGen.generatedLanguages := Seq("Scala", "Java"),
@@ -311,6 +315,7 @@ lazy val pluginTesterJava = Project(id = 
"plugin-tester-java", base = file("plug
   .settings(Dependencies.pluginTester)
   .settings(
     name := s"$pekkoPrefix-plugin-tester-java",
+    javafmtSortImports := false,
     fork := true,
     PB.protocVersion := Dependencies.Versions.googleProtoc,
     ReflectiveCodeGen.generatedLanguages := Seq("Java"),
diff --git 
a/interop-tests/src/test/java/example/myapp/helloworld/grpc/ExceptionGreeterServiceImpl.java
 
b/interop-tests/src/test/java/example/myapp/helloworld/grpc/ExceptionGreeterServiceImpl.java
index b2f75369..ad539704 100644
--- 
a/interop-tests/src/test/java/example/myapp/helloworld/grpc/ExceptionGreeterServiceImpl.java
+++ 
b/interop-tests/src/test/java/example/myapp/helloworld/grpc/ExceptionGreeterServiceImpl.java
@@ -13,64 +13,68 @@
 
 package example.myapp.helloworld.grpc;
 
-//#unary
+// #unary
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.CompletionStage;
-//#unary
+// #unary
 
-//#streaming
+// #streaming
 import org.apache.pekko.NotUsed;
 import org.apache.pekko.stream.javadsl.Source;
-//#streaming
+// #streaming
 
-//#unary
-//#streaming
+// #unary
+// #streaming
 
 import io.grpc.Status;
 import org.apache.pekko.grpc.GrpcServiceException;
 
-//#unary
-//#streaming
+// #unary
+// #streaming
 
 public class ExceptionGreeterServiceImpl implements GreeterService {
-    //#unary
-    // ...
-
-    @Override
-    public CompletionStage<HelloReply> sayHello(HelloRequest in) {
-        if (in.getName().isEmpty()) {
-            CompletableFuture<HelloReply> future = new CompletableFuture<>();
-            future.completeExceptionally(new 
GrpcServiceException(Status.INVALID_ARGUMENT.withDescription("No name found")));
-            return future;
-        } else {
-            return 
CompletableFuture.completedFuture(HelloReply.newBuilder().setMessage("Hi, " + 
in.getName()).build());
-        }
-    }
-    //#unary
-
-    private Source<HelloReply, NotUsed> myResponseSource = null;
-    
-    //#streaming
-    // ...
-
-    @Override
-    public Source<HelloReply, NotUsed> itKeepsReplying(HelloRequest in) {
-      if (in.getName().isEmpty()) {
-            return Source.failed(new 
GrpcServiceException(Status.INVALID_ARGUMENT.withDescription("No name found")));
-        } else {
-            return myResponseSource;
-        }
-    }
-    //#streaming
+  // #unary
+  // ...
 
-    @Override
-    public Source<HelloReply, NotUsed> 
streamHellos(Source<HelloRequest,NotUsed> in) {
-        return null;
+  @Override
+  public CompletionStage<HelloReply> sayHello(HelloRequest in) {
+    if (in.getName().isEmpty()) {
+      CompletableFuture<HelloReply> future = new CompletableFuture<>();
+      future.completeExceptionally(
+          new GrpcServiceException(Status.INVALID_ARGUMENT.withDescription("No 
name found")));
+      return future;
+    } else {
+      return CompletableFuture.completedFuture(
+          HelloReply.newBuilder().setMessage("Hi, " + in.getName()).build());
     }
+  }
+
+  // #unary
+
+  private Source<HelloReply, NotUsed> myResponseSource = null;
 
-    @Override
-    public CompletionStage<HelloReply> itKeepsTalking(Source<HelloRequest, 
NotUsed> in) {
-        return null;
+  // #streaming
+  // ...
+
+  @Override
+  public Source<HelloReply, NotUsed> itKeepsReplying(HelloRequest in) {
+    if (in.getName().isEmpty()) {
+      return Source.failed(
+          new GrpcServiceException(Status.INVALID_ARGUMENT.withDescription("No 
name found")));
+    } else {
+      return myResponseSource;
     }
-    
+  }
+
+  // #streaming
+
+  @Override
+  public Source<HelloReply, NotUsed> streamHellos(Source<HelloRequest, 
NotUsed> in) {
+    return null;
+  }
+
+  @Override
+  public CompletionStage<HelloReply> itKeepsTalking(Source<HelloRequest, 
NotUsed> in) {
+    return null;
+  }
 }
diff --git 
a/interop-tests/src/test/java/org/apache/pekko/grpc/interop/JavaTestServiceImpl.java
 
b/interop-tests/src/test/java/org/apache/pekko/grpc/interop/JavaTestServiceImpl.java
index efa13fb9..4f32937f 100644
--- 
a/interop-tests/src/test/java/org/apache/pekko/grpc/interop/JavaTestServiceImpl.java
+++ 
b/interop-tests/src/test/java/org/apache/pekko/grpc/interop/JavaTestServiceImpl.java
@@ -32,25 +32,26 @@ import io.grpc.testing.integration.TestService;
 /**
  * Implementation of the generated service.
  *
- * Essentially porting the client code from 
[[io.grpc.testing.integration.TestServiceImpl]] against our API's
+ * <p>Essentially porting the client code from 
[[io.grpc.testing.integration.TestServiceImpl]]
+ * against our API's
  *
- * The same implementation is also be found as part of the 'scripted' tests at
+ * <p>The same implementation is also be found as part of the 'scripted' tests 
at
  * 
/sbt-plugin/src/sbt-test/gen-scala-server/00-interop/src/main/java/org/apache/pekko/grpc/JavaTestServiceImpl.scala
  */
 public class JavaTestServiceImpl implements TestService {
   private final Materializer mat;
 
-  private static final Flow<ResponseParameters, StreamingOutputCallResponse, 
NotUsed> parametersToResponseFlow =
-    Flow.<ResponseParameters>create()
-      .map(parameters ->
-      StreamingOutputCallResponse.newBuilder()
-        .setPayload(
-          Payload.newBuilder()
-            .setBody(ByteString.copyFrom(new byte[parameters.getSize()]))
-            .build()
-        )
-        .build()
-    );
+  private static final Flow<ResponseParameters, StreamingOutputCallResponse, 
NotUsed>
+      parametersToResponseFlow =
+          Flow.<ResponseParameters>create()
+              .map(
+                  parameters ->
+                      StreamingOutputCallResponse.newBuilder()
+                          .setPayload(
+                              Payload.newBuilder()
+                                  .setBody(ByteString.copyFrom(new 
byte[parameters.getSize()]))
+                                  .build())
+                          .build());
 
   public JavaTestServiceImpl(Materializer mat) {
     this.mat = mat;
@@ -61,24 +62,25 @@ public class JavaTestServiceImpl implements TestService {
     return 
CompletableFuture.completedFuture(EmptyProtos.Empty.newBuilder().build());
   }
 
-    @Override
-    public CompletionStage<SimpleResponse> unaryCall(SimpleRequest in) {
-        if (in.hasResponseStatus()) {
-            EchoStatus requestStatus = in.getResponseStatus();
-            Status status = 
Status.fromCodeValue(requestStatus.getCode()).withDescription(requestStatus.getMessage());
-            CompletableFuture<SimpleResponse> cf = new CompletableFuture<>();
-            cf.completeExceptionally(new GrpcServiceException(status));
-            return cf;
-        } else {
-            return CompletableFuture.completedFuture(
-                    SimpleResponse.newBuilder()
-                            .setPayload(Payload.newBuilder()
-                                    .setBody(ByteString.copyFrom(new 
byte[in.getResponseSize()]))
-                                    .build())
-                            .build()
-            );
-        }
+  @Override
+  public CompletionStage<SimpleResponse> unaryCall(SimpleRequest in) {
+    if (in.hasResponseStatus()) {
+      EchoStatus requestStatus = in.getResponseStatus();
+      Status status =
+          
Status.fromCodeValue(requestStatus.getCode()).withDescription(requestStatus.getMessage());
+      CompletableFuture<SimpleResponse> cf = new CompletableFuture<>();
+      cf.completeExceptionally(new GrpcServiceException(status));
+      return cf;
+    } else {
+      return CompletableFuture.completedFuture(
+          SimpleResponse.newBuilder()
+              .setPayload(
+                  Payload.newBuilder()
+                      .setBody(ByteString.copyFrom(new 
byte[in.getResponseSize()]))
+                      .build())
+              .build());
     }
+  }
 
   @Override
   public CompletionStage<SimpleResponse> cacheableUnaryCall(SimpleRequest in) {
@@ -86,48 +88,47 @@ public class JavaTestServiceImpl implements TestService {
   }
 
   @Override
-  public Source<StreamingOutputCallResponse, NotUsed> 
streamingOutputCall(StreamingOutputCallRequest in) {
+  public Source<StreamingOutputCallResponse, NotUsed> streamingOutputCall(
+      StreamingOutputCallRequest in) {
     return Source.from(in.getResponseParametersList())
-      .via(parametersToResponseFlow)
-      .mapMaterializedValue(x -> x);
+        .via(parametersToResponseFlow)
+        .mapMaterializedValue(x -> x);
   }
 
   @Override
-  public CompletionStage<StreamingInputCallResponse> 
streamingInputCall(Source<StreamingInputCallRequest, NotUsed> in) {
-    return in
-      .map(i -> i.getPayload().getBody().size())
-      .runFold(0, (Integer x, Integer y)->x+y, mat)
-      .thenApply(sum -> 
StreamingInputCallResponse.newBuilder().setAggregatedPayloadSize(sum).build());
+  public CompletionStage<StreamingInputCallResponse> streamingInputCall(
+      Source<StreamingInputCallRequest, NotUsed> in) {
+    return in.map(i -> i.getPayload().getBody().size())
+        .runFold(0, (Integer x, Integer y) -> x + y, mat)
+        .thenApply(
+            sum -> 
StreamingInputCallResponse.newBuilder().setAggregatedPayloadSize(sum).build());
   }
 
-
   @Override
-  public Source<StreamingOutputCallResponse, NotUsed> 
fullDuplexCall(Source<StreamingOutputCallRequest, NotUsed> in) {
-    return in
-            .map(req -> {
-                if(req.hasResponseStatus()) {
-                    throw new GrpcServiceException(
-                            Status
-                                    
.fromCodeValue(req.getResponseStatus().getCode())
-                                    
.withDescription(req.getResponseStatus().getMessage())
-                    );
-                }else {
-                    return req;
-                }
+  public Source<StreamingOutputCallResponse, NotUsed> fullDuplexCall(
+      Source<StreamingOutputCallRequest, NotUsed> in) {
+    return in.map(
+            req -> {
+              if (req.hasResponseStatus()) {
+                throw new GrpcServiceException(
+                    Status.fromCodeValue(req.getResponseStatus().getCode())
+                        
.withDescription(req.getResponseStatus().getMessage()));
+              } else {
+                return req;
+              }
             })
-      .mapConcat(r -> r.getResponseParametersList())
-      .via(parametersToResponseFlow);
+        .mapConcat(r -> r.getResponseParametersList())
+        .via(parametersToResponseFlow);
   }
 
-
   @Override
-  public Source<StreamingOutputCallResponse, NotUsed> 
halfDuplexCall(Source<StreamingOutputCallRequest, NotUsed> in) {
+  public Source<StreamingOutputCallResponse, NotUsed> halfDuplexCall(
+      Source<StreamingOutputCallRequest, NotUsed> in) {
     return null;
   }
 
   @Override
   public CompletionStage<EmptyProtos.Empty> 
unimplementedCall(EmptyProtos.Empty in) {
-     throw new UnsupportedOperationException();
+    throw new UnsupportedOperationException();
   }
-
 }
diff --git a/plugin-tester-java/src/main/java/example/myapp/CombinedServer.java 
b/plugin-tester-java/src/main/java/example/myapp/CombinedServer.java
index c592ae9f..34f4dc89 100644
--- a/plugin-tester-java/src/main/java/example/myapp/CombinedServer.java
+++ b/plugin-tester-java/src/main/java/example/myapp/CombinedServer.java
@@ -23,18 +23,18 @@ import com.typesafe.config.ConfigFactory;
 import java.util.Arrays;
 import java.util.concurrent.CompletionStage;
 
-//#import
+// #import
 import org.apache.pekko.grpc.javadsl.ServiceHandler;
 import org.apache.pekko.http.javadsl.model.HttpRequest;
 import org.apache.pekko.http.javadsl.model.HttpResponse;
 import org.apache.pekko.japi.function.Function;
 
-//#import
+// #import
 
-//#grpc-web
+// #grpc-web
 import org.apache.pekko.grpc.javadsl.WebHandler;
 
-//#grpc-web
+// #grpc-web
 
 import example.myapp.helloworld.*;
 import example.myapp.helloworld.grpc.*;
@@ -43,36 +43,38 @@ import example.myapp.echo.grpc.*;
 
 class CombinedServer {
   public static void main(String[] args) {
-      // important to enable HTTP/2 in ActorSystem's config
-      Config conf = ConfigFactory.parseString("pekko.http.server.enable-http2 
= on")
-        .withFallback(ConfigFactory.defaultApplication());
-      ActorSystem sys = ActorSystem.create("HelloWorld", conf);
-      Materializer mat = SystemMaterializer.get(sys).materializer();
+    // important to enable HTTP/2 in ActorSystem's config
+    Config conf =
+        ConfigFactory.parseString("pekko.http.server.enable-http2 = on")
+            .withFallback(ConfigFactory.defaultApplication());
+    ActorSystem sys = ActorSystem.create("HelloWorld", conf);
+    Materializer mat = SystemMaterializer.get(sys).materializer();
 
-      //#concatOrNotFound
-      Function<HttpRequest, CompletionStage<HttpResponse>> greeterService =
-          GreeterServiceHandlerFactory.create(new GreeterServiceImpl(mat), 
sys);
-      Function<HttpRequest, CompletionStage<HttpResponse>> echoService =
+    // #concatOrNotFound
+    Function<HttpRequest, CompletionStage<HttpResponse>> greeterService =
+        GreeterServiceHandlerFactory.create(new GreeterServiceImpl(mat), sys);
+    Function<HttpRequest, CompletionStage<HttpResponse>> echoService =
         EchoServiceHandlerFactory.create(new EchoServiceImpl(), sys);
-      @SuppressWarnings("unchecked")
-      Function<HttpRequest, CompletionStage<HttpResponse>> serviceHandlers =
+    @SuppressWarnings("unchecked")
+    Function<HttpRequest, CompletionStage<HttpResponse>> serviceHandlers =
         ServiceHandler.concatOrNotFound(greeterService, echoService);
 
-      Http.get(sys)
-          .newServerAt("127.0.0.1", 8090)
-          .bind(serviceHandlers)
-      //#concatOrNotFound
-      .thenAccept(binding -> System.out.println("gRPC server bound to: " + 
binding.localAddress()));
+    Http.get(sys)
+        .newServerAt("127.0.0.1", 8090)
+        .bind(serviceHandlers)
+        // #concatOrNotFound
+        .thenAccept(
+            binding -> System.out.println("gRPC server bound to: " + 
binding.localAddress()));
 
-      //#grpc-web
-      Function<HttpRequest, CompletionStage<HttpResponse>> 
grpcWebServiceHandlers =
-          WebHandler.grpcWebHandler(Arrays.asList(greeterService, 
echoService), sys, mat);
+    // #grpc-web
+    Function<HttpRequest, CompletionStage<HttpResponse>> 
grpcWebServiceHandlers =
+        WebHandler.grpcWebHandler(Arrays.asList(greeterService, echoService), 
sys, mat);
 
-      Http.get(sys)
+    Http.get(sys)
         .newServerAt("127.0.0.1", 8090)
         .bind(grpcWebServiceHandlers)
-      //#grpc-web
-      .thenAccept(binding -> System.out.println("gRPC-Web server bound to: " + 
binding.localAddress()));
-
+        // #grpc-web
+        .thenAccept(
+            binding -> System.out.println("gRPC-Web server bound to: " + 
binding.localAddress()));
   }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to