From 6e2be02077815ba0009d59d562bbf9973dcf1744 Mon Sep 17 00:00:00 2001 From: David Ankin Date: Tue, 17 Dec 2024 13:43:55 -0500 Subject: [PATCH 1/2] Use @generated=omit when configuring gRPC plugins See gh-1682 --- .../springgrpc/GrpcGradleGroovyBuildCustomizer.java | 5 ++++- .../springgrpc/GrpcGradleKotlinBuildCustomizer.java | 9 +++++---- .../dependency/springgrpc/GrpcMavenBuildCustomizer.java | 1 + .../SpringGrpcProjectGenerationConfigurationTests.java | 3 +++ 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/start-site/src/main/java/io/spring/start/site/extension/dependency/springgrpc/GrpcGradleGroovyBuildCustomizer.java b/start-site/src/main/java/io/spring/start/site/extension/dependency/springgrpc/GrpcGradleGroovyBuildCustomizer.java index f3f4f120b8..080c63de77 100644 --- a/start-site/src/main/java/io/spring/start/site/extension/dependency/springgrpc/GrpcGradleGroovyBuildCustomizer.java +++ b/start-site/src/main/java/io/spring/start/site/extension/dependency/springgrpc/GrpcGradleGroovyBuildCustomizer.java @@ -38,7 +38,10 @@ protected void customizeExtensions(GradleExtensionContainer extensions) { protobuf.nested("plugins", (plugins) -> plugins.nested("grpc", (grpc) -> grpc.attribute("artifact", quote("io.grpc:protoc-gen-grpc-java")))); protobuf.nested("generateProtoTasks", (generateProtoTasks) -> generateProtoTasks.nested("all()*.plugins", - (plugins) -> plugins.nested("grpc", (grpc) -> grpc.invoke("option", quote("jakarta_omit"))))); + (plugins) -> plugins.nested("grpc", (grpc) -> { + grpc.invoke("option", quote("jakarta_omit")); + grpc.invoke("option", quote("@generated=omit")); + }))); }); } diff --git a/start-site/src/main/java/io/spring/start/site/extension/dependency/springgrpc/GrpcGradleKotlinBuildCustomizer.java b/start-site/src/main/java/io/spring/start/site/extension/dependency/springgrpc/GrpcGradleKotlinBuildCustomizer.java index faf2dc4b5a..123643a64b 100644 --- a/start-site/src/main/java/io/spring/start/site/extension/dependency/springgrpc/GrpcGradleKotlinBuildCustomizer.java +++ b/start-site/src/main/java/io/spring/start/site/extension/dependency/springgrpc/GrpcGradleKotlinBuildCustomizer.java @@ -38,10 +38,11 @@ protected void customizeExtensions(GradleExtensionContainer extensions) { protobuf.importType("com.google.protobuf.gradle.id"); protobuf.nested("plugins", (plugins) -> plugins.nested("id(\"grpc\")", (grpc) -> grpc.attribute("artifact", quote("io.grpc:protoc-gen-grpc-java")))); - protobuf.nested("generateProtoTasks", - (generateProtoTasks) -> generateProtoTasks.nested("all().forEach", - (forEach) -> forEach.nested("it.plugins", (plugins) -> plugins.nested("id(\"grpc\")", - (grpc) -> grpc.invoke("option", quote("jakarta_omit")))))); + protobuf.nested("generateProtoTasks", (generateProtoTasks) -> generateProtoTasks.nested("all().forEach", + (forEach) -> forEach.nested("it.plugins", (plugins) -> plugins.nested("id(\"grpc\")", (grpc) -> { + grpc.invoke("option", quote("jakarta_omit")); + grpc.invoke("option", quote("@generated=omit")); + })))); }); } diff --git a/start-site/src/main/java/io/spring/start/site/extension/dependency/springgrpc/GrpcMavenBuildCustomizer.java b/start-site/src/main/java/io/spring/start/site/extension/dependency/springgrpc/GrpcMavenBuildCustomizer.java index b0304b1321..d5e2fad0e1 100644 --- a/start-site/src/main/java/io/spring/start/site/extension/dependency/springgrpc/GrpcMavenBuildCustomizer.java +++ b/start-site/src/main/java/io/spring/start/site/extension/dependency/springgrpc/GrpcMavenBuildCustomizer.java @@ -80,6 +80,7 @@ private void addProtobufPlugin(MavenPluginContainer plugins, VersionProperty pro plugin.execution("compile", (execution) -> { execution.goal("compile").goal("compile-custom"); execution.configuration((configuration) -> configuration.add("pluginParameter", "jakarta_omit")); + execution.configuration((configuration) -> configuration.add("pluginParameter", "@generated=omit")); }); }); } diff --git a/start-site/src/test/java/io/spring/start/site/extension/dependency/springgrpc/SpringGrpcProjectGenerationConfigurationTests.java b/start-site/src/test/java/io/spring/start/site/extension/dependency/springgrpc/SpringGrpcProjectGenerationConfigurationTests.java index a4dbc8c0b9..2a51965895 100644 --- a/start-site/src/test/java/io/spring/start/site/extension/dependency/springgrpc/SpringGrpcProjectGenerationConfigurationTests.java +++ b/start-site/src/test/java/io/spring/start/site/extension/dependency/springgrpc/SpringGrpcProjectGenerationConfigurationTests.java @@ -77,6 +77,7 @@ void shouldAddGrpcPluginAndConfigurationForGradleGroovy() { all()*.plugins { grpc { option 'jakarta_omit' + option '@generated=omit' } } } @@ -105,6 +106,7 @@ void shouldAddGrpcPluginAndConfigurationForGradleKotlin() { it.plugins { id("grpc") { option("jakarta_omit") + option("@generated=omit") } } } @@ -159,6 +161,7 @@ void shouldAddProtobufPluginForMaven() { jakarta_omit + @generated=omit From 3f286a882e2a798931832136b21e3aeea2b6bd0a Mon Sep 17 00:00:00 2001 From: Moritz Halbritter Date: Thu, 19 Dec 2024 08:42:39 +0100 Subject: [PATCH 2/2] Polish "Use @generated=omit when configuring gRPC plugins" See gh-1682 --- .../dependency/springgrpc/GrpcMavenBuildCustomizer.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/start-site/src/main/java/io/spring/start/site/extension/dependency/springgrpc/GrpcMavenBuildCustomizer.java b/start-site/src/main/java/io/spring/start/site/extension/dependency/springgrpc/GrpcMavenBuildCustomizer.java index d5e2fad0e1..a7a021c727 100644 --- a/start-site/src/main/java/io/spring/start/site/extension/dependency/springgrpc/GrpcMavenBuildCustomizer.java +++ b/start-site/src/main/java/io/spring/start/site/extension/dependency/springgrpc/GrpcMavenBuildCustomizer.java @@ -79,8 +79,10 @@ private void addProtobufPlugin(MavenPluginContainer plugins, VersionProperty pro }); plugin.execution("compile", (execution) -> { execution.goal("compile").goal("compile-custom"); - execution.configuration((configuration) -> configuration.add("pluginParameter", "jakarta_omit")); - execution.configuration((configuration) -> configuration.add("pluginParameter", "@generated=omit")); + execution.configuration((configuration) -> { + configuration.add("pluginParameter", "jakarta_omit"); + configuration.add("pluginParameter", "@generated=omit"); + }); }); }); }