-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathbuild.gradle.kts
126 lines (108 loc) · 3.81 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
import com.google.protobuf.gradle.builtins
import com.google.protobuf.gradle.generateProtoTasks
import com.google.protobuf.gradle.id
import com.google.protobuf.gradle.ofSourceSet
import com.google.protobuf.gradle.plugins
import com.google.protobuf.gradle.protobuf
import com.google.protobuf.gradle.protoc
plugins {
kotlin("jvm") version "1.7.0"
id("com.google.protobuf") version "0.8.18"
id("org.springframework.boot") version "2.7.1"
id("org.jlleitschuh.gradle.ktlint") version "10.3.0"
}
repositories {
mavenLocal()
mavenCentral()
google()
}
val grpcVersion = extra["grpcVersion"]
val protobufVersion = extra["protobufVersion"]
val grpcKotlinVersion = extra["grpcKotlinVersion"]
val coroutinesVersion = extra["coroutinesVersion"]
val springBootVersion = extra["org.springframework.boot.version"]
dependencies {
implementation("io.grpc:grpc-bom:$grpcVersion")
implementation(platform("org.springframework.boot:spring-boot-dependencies:$springBootVersion"))
implementation(kotlin("stdlib"))
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion")
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("io.grpc:grpc-stub:$grpcVersion")
implementation("io.grpc:grpc-protobuf:$grpcVersion")
implementation("com.google.protobuf:protobuf-java-util:$protobufVersion")
implementation("com.google.protobuf:protobuf-kotlin:$protobufVersion")
implementation("io.grpc:grpc-kotlin-stub:$grpcKotlinVersion")
runtimeOnly("org.jetbrains.kotlin:kotlin-reflect:1.1.51")
// implementation("io.grpc:grpc-netty-shaded:$grpcVersion")
implementation("net.devh:grpc-server-spring-boot-starter:2.14.0.RELEASE") /*{
exclude("io.grpc:grpc-netty-shaded")
}*/
// needed to help test protobuf decoding independent of HTTP/2 support in ZAP
implementation("net.devh:grpc-client-spring-boot-starter:2.13.1.RELEASE")
implementation("net.devh:grpc-server-spring-boot-starter:2.14.0.RELEASE")
implementation("org.springframework.boot:spring-boot-starter-web")
testImplementation("org.junit.jupiter:junit-jupiter:5.5.2")
implementation("org.postgresql:postgresql")
}
ktlint {
filter {
exclude { it.file.absolutePath.contains("generated") }
}
}
sourceSets {
val main by getting { }
main.java.srcDirs("build/generated/source/proto/main/java")
main.java.srcDirs("build/generated/source/proto/main/grpc")
main.java.srcDirs("build/generated/source/proto/main/kotlin")
main.java.srcDirs("build/generated/source/proto/main/grpckt")
}
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(11))
}
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().all {
kotlinOptions {
freeCompilerArgs = listOf("-opt-in=kotlin.RequiresOptIn")
}
}
sourceSets {
main {
proto {
srcDir("protos")
}
}
}
protobuf {
protoc {
artifact = "com.google.protobuf:protoc:$protobufVersion"
}
plugins {
id("grpc") { artifact = "io.grpc:protoc-gen-grpc-java:$grpcVersion" }
id("grpckt") {
artifact = "io.grpc:protoc-gen-grpc-kotlin:$grpcKotlinVersion:jdk8@jar"
}
}
generateProtoTasks {
ofSourceSet("main")
.forEach {
it.plugins {
id("grpc")
id("grpckt")
}
it.builtins {
id("kotlin")
}
it.generateDescriptorSet = true
it.descriptorSetOptions.path = "${buildDir.path}/resources/main/descriptor_set.pb"
it.descriptorSetOptions.includeSourceInfo = true
}
}
}
tasks.test {
useJUnitPlatform()
}
tasks.bootJar {
archiveBaseName.set("vuln-grpc-kotlin")
archiveVersion.set("0.1.0")
}