83 lines
2.2 KiB
Groovy
83 lines
2.2 KiB
Groovy
plugins {
|
|
id 'java'
|
|
id 'com.google.protobuf'
|
|
id 'idea'
|
|
id "com.google.osdetector"
|
|
}
|
|
|
|
configurations {
|
|
|
|
// For grpc python codegen.
|
|
python {
|
|
canBeResolved = false
|
|
canBeConsumed = true
|
|
}
|
|
// For Swift Codegen
|
|
swift {
|
|
canBeConsumed = true
|
|
canBeResolved = false
|
|
}
|
|
}
|
|
|
|
protobuf {
|
|
protoc { artifact = 'com.google.protobuf:protoc:3.11.0' }
|
|
plugins {
|
|
grpc {
|
|
artifact = 'io.grpc:protoc-gen-grpc-java:1.28.1' // CURRENT_GRPC_VERSION
|
|
}
|
|
grpc_python {
|
|
path = "$projectDir/grpc_plugins/grpc_python_plugin_1.28.1-${osdetector.classifier}"
|
|
}
|
|
if(osdetector.os != 'windows'){
|
|
swift {
|
|
path = "$projectDir/grpc_plugins/protoc-gen-swift"
|
|
}
|
|
grpc_swift {
|
|
path = "$projectDir/grpc_plugins/protoc-gen-grpc-swift-$osdetector.classifier"
|
|
}
|
|
}
|
|
}
|
|
generateProtoTasks {
|
|
all().each { task ->
|
|
task.builtins {
|
|
java { option 'lite' }
|
|
|
|
python {}
|
|
}
|
|
task.plugins {
|
|
grpc { // Options added to --grpc_out
|
|
option 'lite'
|
|
}
|
|
grpc_python {
|
|
outputSubDir = 'python'
|
|
}
|
|
if(osdetector.os != 'windows'){
|
|
swift{}
|
|
grpc_swift {
|
|
outputSubDir = 'swift'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
task packPythonGrpc(type: Zip, dependsOn: protobuf.generateProtoTasks.all()) {
|
|
from protobuf.generatedFilesBaseDir + '/main/python'
|
|
}
|
|
|
|
task packSwiftGrpc(type: Zip, dependsOn: protobuf.generateProtoTasks.all()) {
|
|
from protobuf.generatedFilesBaseDir + '/main/swift'
|
|
}
|
|
|
|
artifacts {
|
|
python(packPythonGrpc)
|
|
swift(packSwiftGrpc)
|
|
}
|
|
|
|
dependencies {
|
|
implementation 'io.grpc:grpc-okhttp:1.28.1' // CURRENT_GRPC_VERSION
|
|
implementation 'io.grpc:grpc-protobuf-lite:1.28.1' // CURRENT_GRPC_VERSION
|
|
implementation 'io.grpc:grpc-stub:1.28.1' // CURRENT_GRPC_VERSION
|
|
implementation 'javax.annotation:javax.annotation-api:1.2'
|
|
} |