/
build.gradle.kts
69 lines (62 loc) · 1.92 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import com.google.protobuf.gradle.*
import org.gradle.kotlin.dsl.provider.gradleKotlinDslOf
// A minimal example Java project that uses the protobuf plugin.
// To build it:
// $ ./gradlew clean build
plugins {
java
idea
id("com.google.protobuf") version "0.8.8"
}
repositories {
maven("https://plugins.gradle.org/m2/")
}
sourceSets{
create("sample"){
proto {
srcDir("src/sample/protobuf")
}
}
}
dependencies {
compile("com.google.protobuf:protobuf-java:3.6.1")
compile("io.grpc:grpc-stub:1.15.1")
compile("io.grpc:grpc-protobuf:1.15.1")
if (JavaVersion.current().isJava9Compatible) {
// Workaround for @javax.annotation.Generated
// see: https://github.com/grpc/grpc-java/issues/3633
compile("javax.annotation:javax.annotation-api:1.3.1")
}
// Extra proto source files besides the ones residing under
// "src/main".
protobuf(files("lib/protos.tar.gz"))
protobuf(files("ext/"))
// Adding dependency for configuration from custom sourceSet
"sampleProtobuf"(files("ext/"))
testCompile("junit:junit:4.12")
// Extra proto source files for test besides the ones residing under
// "src/test".
testProtobuf(files("lib/protos-test.tar.gz"))
}
protobuf {
protoc {
// The artifact spec for the Protobuf Compiler
artifact = "com.google.protobuf:protoc:3.6.1"
}
plugins {
// Optional: an artifact spec for a protoc plugin, with "grpc" as
// the identifier, which can be referred to in the "plugins"
// container of the "generateProtoTasks" closure.
id("grpc") {
artifact = "io.grpc:protoc-gen-grpc-java:1.15.1"
}
}
generateProtoTasks {
ofSourceSet("main").forEach {
it.plugins {
// Apply the "grpc" plugin whose spec is defined above, without options.
id("grpc")
}
}
}
}