build.gradle.kts 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import com.google.protobuf.gradle.*
  2. plugins {
  3. id("otel.java-conventions")
  4. id("com.google.protobuf")
  5. }
  6. val grpcVersion = "1.6.0"
  7. dependencies {
  8. api(project(":testing-common"))
  9. api("io.grpc:grpc-core:$grpcVersion")
  10. api("io.grpc:grpc-protobuf:$grpcVersion")
  11. api("io.grpc:grpc-services:$grpcVersion")
  12. api("io.grpc:grpc-stub:$grpcVersion")
  13. implementation("javax.annotation:javax.annotation-api:1.3.2")
  14. implementation("com.google.guava:guava")
  15. api("org.junit-pioneer:junit-pioneer")
  16. implementation("io.opentelemetry:opentelemetry-api")
  17. }
  18. tasks {
  19. compileJava {
  20. with(options) {
  21. // We generate stubs using an old version of protobuf to test old versions of gRPC,
  22. // where this lint error triggers.
  23. compilerArgs.add("-Xlint:-cast")
  24. }
  25. }
  26. }
  27. protobuf {
  28. protoc {
  29. // The artifact spec for the Protobuf Compiler
  30. artifact = "com.google.protobuf:protoc:3.3.0"
  31. if (osdetector.os == "osx") {
  32. // Always use x86_64 version as ARM binary is not available
  33. artifact += ":osx-x86_64"
  34. }
  35. }
  36. plugins {
  37. id("grpc") {
  38. artifact = "io.grpc:protoc-gen-grpc-java:$grpcVersion"
  39. if (osdetector.os == "osx") {
  40. // Always use x86_64 version as ARM binary is not available
  41. artifact += ":osx-x86_64"
  42. }
  43. }
  44. }
  45. generateProtoTasks {
  46. all().configureEach {
  47. plugins {
  48. id("grpc")
  49. }
  50. }
  51. }
  52. }
  53. afterEvaluate {
  54. // Classpath when compiling protos, we add dependency management directly
  55. // since it doesn't follow Gradle conventions of naming / properties.
  56. dependencies {
  57. add("compileProtoPath", platform(project(":dependencyManagement")))
  58. add("testCompileProtoPath", platform(project(":dependencyManagement")))
  59. }
  60. }