forked from GoogleCloudPlatform/kotlin-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
97 lines (82 loc) · 2.48 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
plugins {
application
kotlin("jvm") version "1.9.23"
id("com.google.protobuf") version "0.9.4"
id("org.jlleitschuh.gradle.ktlint") version "12.1.0"
}
repositories {
mavenLocal()
google()
mavenCentral()
}
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(8))
}
}
kotlin.sourceSets.all {
languageSettings.optIn("kotlin.RequiresOptIn")
}
val grpcVersion = "1.62.2"
val grpcKotlinVersion = "1.4.1"
val protobufVersion = "3.25.3"
val coroutinesVersion = "1.8.0"
dependencies {
implementation(kotlin("stdlib"))
implementation("javax.annotation:javax.annotation-api:1.3.2")
implementation("io.grpc:grpc-kotlin-stub:$grpcKotlinVersion")
implementation("io.grpc:grpc-protobuf:$grpcVersion")
implementation("com.google.protobuf:protobuf-kotlin:$protobufVersion")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion")
runtimeOnly("io.grpc:grpc-netty-shaded:$grpcVersion")
}
protobuf {
protoc {
artifact = "com.google.protobuf:protoc:$protobufVersion"
}
plugins {
create("grpc") {
artifact = "io.grpc:protoc-gen-grpc-java:$grpcVersion"
}
create("grpckt") {
artifact = "io.grpc:protoc-gen-grpc-kotlin:$grpcKotlinVersion:jdk8@jar"
}
}
generateProtoTasks {
all().forEach {
it.plugins {
create("grpc")
create("grpckt")
}
it.builtins {
create("kotlin")
}
}
}
}
application {
mainClass.set("io.grpc.examples.helloworld.HelloWorldServerKt")
}
ktlint {
filter {
// this doesn't work: https://github.com/JLLeitschuh/ktlint-gradle/issues/746
exclude("**/generated/**")
}
}
tasks.register<JavaExec>("HelloWorldClient") {
dependsOn("classes")
classpath = sourceSets["main"].runtimeClasspath
mainClass.set("io.grpc.examples.helloworld.HelloWorldClientKt")
}
val otherStartScripts =
tasks.register<CreateStartScripts>("otherStartScripts") {
mainClass.set("io.grpc.examples.helloworld.HelloWorldClientKt")
applicationName = "HelloWorldClientKt"
outputDir = tasks.named<CreateStartScripts>("startScripts").get().outputDir
classpath = tasks.named<CreateStartScripts>("startScripts").get().classpath
}
tasks.named("startScripts") {
dependsOn(otherStartScripts)
}
task("stage").dependsOn("installDist")
tasks.replace("assemble").dependsOn(":installDist")