-
Notifications
You must be signed in to change notification settings - Fork 8
/
build.gradle.kts
123 lines (108 loc) · 3.43 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
import com.google.protobuf.gradle.*
import org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
import org.gradle.language.jvm.tasks.ProcessResources
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
kotlin("jvm") version "1.6.0"
idea
id("org.jlleitschuh.gradle.ktlint") version "11.0.0"
id("maven-publish")
id("com.vanniktech.maven.publish") version "0.22.0"
id("com.google.protobuf") version "0.9.4"
}
group = "com.statsig"
version = project.properties["VERSION_NAME"]!!
repositories {
mavenCentral()
maven { setUrl("https://jitpack.io") }
}
configure<org.jlleitschuh.gradle.ktlint.KtlintExtension> {
verbose.set(true)
disabledRules.set(setOf("no-wildcard-imports"))
filter {
exclude("**/generated/**")
}
}
dependencies {
protobuf(files("api-interface-definitions/protos/"))
testImplementation("junit:junit:4.13.2")
testImplementation("com.squareup.okhttp3:mockwebserver:4.10.0")
testImplementation("io.mockk:mockk:1.13.2")
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4")
testImplementation("io.grpc:grpc-testing:1.66.0")
implementation("com.google.code.gson:gson:2.9.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.6.4")
implementation("com.squareup.okhttp3:okhttp:4.11.0")
implementation("com.github.ua-parser:uap-java:1.6.1")
implementation("com.statsig:ip3country:0.1.5")
implementation("com.squareup.okhttp3:logging-interceptor:4.11.0")
// GRPC Dependencies
implementation("io.grpc:grpc-netty-shaded:1.66.0")
implementation("io.grpc:grpc-stub:1.66.0")
implementation("io.grpc:grpc-protobuf:1.66.0")
implementation("org.apache.tomcat:annotations-api:6.0.53")
}
val sourcesJar by tasks.registering(Jar::class) {
archiveClassifier.set("sources")
from(sourceSets.main.get().allSource)
}
publishing {
publications {
register("mavenJava", MavenPublication::class) {
from(components["java"])
artifact(sourcesJar.get())
}
}
}
tasks.test {
useJUnit()
testLogging {
events("passed", "skipped", "failed")
exceptionFormat = FULL
showExceptions = true
showCauses = true
showStackTraces = true
}
}
configure<ProcessResources>("processResources") {
filesMatching("statsigsdk.properties") {
expand(project.properties)
}
}
inline fun <reified C> Project.configure(name: String, configuration: C.() -> Unit) {
(this.tasks.getByName(name) as C).configuration()
}
tasks.withType<KotlinCompile>() {
kotlinOptions.jvmTarget = "1.8"
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
protobuf {
protoc {
artifact = "com.google.protobuf:protoc:3.25.3"
}
plugins {
id("grpc") {
artifact = "io.grpc:protoc-gen-grpc-java:1.66.0"
}
}
generateProtoTasks {
all().forEach { task ->
task.plugins {
id("grpc")
}
task.doLast {
val outputPath = task.outputs.files.getAsPath()
copy {
from("$outputPath/grpc")
from("$outputPath/java")
into("$projectDir/src/main/java")
}
delete("$outputPath")
}
}
}
}