-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.gradle.kts
110 lines (92 loc) · 2.25 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
import com.google.protobuf.gradle.id
plugins {
application
kotlin("jvm")
kotlin("plugin.serialization")
id("com.google.protobuf")
id("org.jetbrains.kotlinx.kover")
}
repositories {
mavenCentral()
}
dependencies {
implementation(libs.bundles.protobuf)
implementation(libs.bundles.kotlinx)
implementation(project(":runtime-common"))
testImplementation(libs.bundles.junit)
}
tasks.withType<Test> {
// Use JUnit Platform for unit tests.
useJUnitPlatform()
}
tasks.named("generateProto") {
dependsOn(project(":app").tasks.jar)
dependsOn("cleanSources")
}
tasks.register("copySources", type = Sync::class) {
dependsOn("generateProto")
from(layout.buildDirectory.dir("generated/source/proto/main/kotlinx-protobuf-gen"))
into("src/main/kotlin")
}
tasks.register("cleanGeneratedFiles", type = Delete::class) {
dependsOn("copySources")
delete(layout.buildDirectory.dir("generated/source/proto/main/kotlinx-protobuf-gen"))
}
tasks.register("cleanSources") {
doFirst {
delete("src/main/kotlin")
}
}
tasks.named("compileKotlin") {
dependsOn("cleanGeneratedFiles")
}
sourceSets {
main {
proto {
srcDir("$rootDir/testProtos")
}
}
}
kover {
reports {
filters {
includes {
this.packages("testgen")
this.packages("testgen.*")
}
}
}
}
protobuf {
protoc {
artifact = "com.google.protobuf:protoc:${libs.versions.protobuf.get()}"
}
plugins {
id("kotlinx-protobuf-gen") {
path = project(":app").tasks.jar.get().archiveFile.get().asFile.absolutePath
}
}
generateProtoTasks {
all().forEach {
it.plugins {
id("kotlinx-protobuf-gen") {
option("package_prefix=testgen")
option("use_well_known_types")
}
}
}
}
}
// Lint
tasks.named("runKtlintCheckOverMainSourceSet") {
dependsOn("cleanGeneratedFiles")
}
ktlint {
filter {
exclude { entry ->
val condition =
entry.file.toString().contains(".proto.kt") || entry.file.toString().contains("generated")
condition
}
}
}