1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- plugins {
- id "com.google.protobuf" version "0.8.19"
- id 'java-library'
- }
- group 'com.incubator.message'
- version '1.0-SNAPSHOT'
- dependencies {
- testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.0'
- testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.0'
- api 'com.alibaba.fastjson2:fastjson2:2.0.53'
- api 'com.google.protobuf:protobuf-java:4.28.3'
- api 'io.grpc:grpc-all:1.68.1'
- }
- protobuf {
- // 配置 Protocol Buffers 编译器版本
- protoc {
- artifact = 'com.google.protobuf:protoc:4.28.3'
- }
- // 配置 gRPC 插件
- plugins {
- grpc {
- artifact = 'io.grpc:protoc-gen-grpc-java:1.68.1'
- }
- }
- // 自动为所有 proto 生成 Java 和 gRPC 代码
- generateProtoTasks {
- all().forEach {
- it.plugins {
- grpc {}
- }
- }
- }
- }
- sourceSets {
- main {
- java {
- // 将生成的代码目录添加到主代码源路径
- srcDirs 'build/generated/source/proto/main/grpc'
- srcDirs 'build/generated/source/proto/main/java'
- }
- }
- }
- tasks {
- // 为构建任务添加依赖
- build.dependsOn("generateProto")
- // 配置测试任务,启用 JUnit 平台
- test {
- useJUnitPlatform()
- testLogging {
- events("PASSED", "FAILED", "SKIPPED")
- }
- }
- }
|