Created
February 28, 2021 15:07
-
-
Save sasaken555/877409fcfff4d681eaeb0e15e097582a to your computer and use it in GitHub Desktop.
gRPC server build spec for Spring Boot application
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
buildscript { | |
repositories { | |
mavenCentral() | |
} | |
dependencies { | |
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.15' | |
} | |
} | |
plugins { | |
id 'org.springframework.boot' version '2.4.3' | |
id 'io.spring.dependency-management' version '1.0.11.RELEASE' | |
id 'java' | |
id "com.google.protobuf" version "0.8.15" | |
} | |
group = 'com.example' | |
version = '0.0.1-SNAPSHOT' | |
sourceCompatibility = '11' | |
repositories { | |
mavenCentral() | |
} | |
def grpcVersion = '1.36.0' // CURRENT_GRPC_VERSION | |
def protobufVersion = '3.14.0' | |
def protocVersion = protobufVersion | |
dependencies { | |
implementation 'io.github.lognet:grpc-spring-boot-starter:4.4.4' | |
} | |
// gRPC build settings are below. | |
// 'gradle clean' deletes whole protoGen directory, | |
// so consider moving these settings to an another project. | |
sourceSets { | |
main { | |
java { | |
srcDir 'src/main/protoGen' | |
} | |
} | |
} | |
protobuf { | |
protoc { | |
artifact = "com.google.protobuf:protoc:${protocVersion}" | |
} | |
plugins { | |
grpc { | |
artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}" | |
} | |
} | |
generateProtoTasks { | |
ofSourceSet('main').each { task -> | |
task.builtins { | |
java { | |
outputSubDir = 'protoGen' | |
} | |
} | |
task.plugins { | |
grpc { | |
outputSubDir = 'protoGen' | |
} | |
} | |
} | |
} | |
generatedFilesBaseDir = "$projectDir/src/" | |
} | |
task cleanProtoGen { | |
doFirst { | |
delete("$projectDir/src/main/protoGen") | |
} | |
} | |
clean.dependsOn cleanProtoGen |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment