-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathbuild.gradle.kts
281 lines (238 loc) · 8.83 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
import com.google.protobuf.gradle.id
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
val configVersion: String by System.getProperties()
val detektVersion: String by System.getProperties()
// val kotestPluginVersion: String by System.getProperties()
// val kotlinterVersion: String by System.getProperties()
val kotlinVersion: String by System.getProperties()
val koverVersion: String by System.getProperties()
val protobufVersion: String by System.getProperties()
val shadowVersion: String by System.getProperties()
val versionsVersion: String by System.getProperties()
idea
java
`maven-publish`
kotlin("jvm") version kotlinVersion
kotlin("plugin.serialization") version kotlinVersion
id("com.google.protobuf") version protobufVersion // Keep in sync with grpc
// id ("org.jmailen.kotlinter)" version kotlinterVersion
id("com.github.ben-manes.versions") version versionsVersion
id("com.github.johnrengelman.shadow") version shadowVersion
id("com.github.gmazzo.buildconfig") version configVersion
id("org.jetbrains.kotlinx.kover") version koverVersion
id("io.gitlab.arturbosch.detekt") version detektVersion
// Turn these off until jacoco fixes their kotlin 1.5.0 SMAP issue
// id("jacoco")
// id("com.github.kt3k.coveralls") version "2.12.0"
}
group = "io.prometheus"
version = "1.23.1"
buildConfig {
packageName("io.prometheus")
buildConfigField("String", "APP_NAME", "\"${project.name}\"")
buildConfigField("String", "APP_VERSION", "\"${project.version}\"")
buildConfigField("String", "APP_RELEASE_DATE", "\"12/09/2024\"")
buildConfigField("long", "BUILD_TIME", "${System.currentTimeMillis()}L")
}
repositories {
mavenLocal()
google()
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
val annotationVersion: String by project
val datetimeVersion: String by project
val dropwizardVersion: String by project
val gengrpcVersion: String by project
val grpcVersion: String by project
val jcommanderVersion: String by project
val jettyVersion: String by project
val junitVersion: String by project
val kluentVersion: String by project
val kotlinVersion: String by project
val ktorVersion: String by project
val logbackVersion: String by project
val loggingVersion: String by project
val tcnativeVersion: String by project
val prometheusVersion: String by project
val protobufVersion: String by project
val protocVersion: String by project
val serializationVersion: String by project
val slf4jVersion: String by project
val typesafeVersion: String by project
val utilsVersion: String by project
val zipkinVersion: String by project
dependencies {
implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:$serializationVersion")
implementation("io.grpc:grpc-netty-shaded:$grpcVersion")
implementation("io.grpc:grpc-protobuf:$grpcVersion")
implementation("io.grpc:grpc-stub:$grpcVersion")
implementation("io.grpc:grpc-services:$grpcVersion")
// implementation("com.google.protobuf:protobuf-java:$protobufVersion")
// implementation("com.google.protobuf:protobuf-java-util:$protobufVersion")
implementation("io.grpc:grpc-kotlin-stub:$gengrpcVersion")
// Required
implementation("io.netty:netty-tcnative-boringssl-static:$tcnativeVersion")
implementation("com.github.pambrose.common-utils:core-utils:$utilsVersion")
implementation("com.github.pambrose.common-utils:corex-utils:$utilsVersion")
implementation("com.github.pambrose.common-utils:dropwizard-utils:$utilsVersion")
implementation("com.github.pambrose.common-utils:guava-utils:$utilsVersion")
implementation("com.github.pambrose.common-utils:grpc-utils:$utilsVersion")
implementation("com.github.pambrose.common-utils:jetty-utils:$utilsVersion")
implementation("com.github.pambrose.common-utils:ktor-client-utils:$utilsVersion")
implementation("com.github.pambrose.common-utils:prometheus-utils:$utilsVersion")
implementation("com.github.pambrose.common-utils:service-utils:$utilsVersion")
implementation("com.github.pambrose.common-utils:zipkin-utils:$utilsVersion")
implementation("org.eclipse.jetty:jetty-servlet:$jettyVersion")
implementation("javax.annotation:javax.annotation-api:$annotationVersion")
implementation("org.jcommander:jcommander:$jcommanderVersion")
implementation("com.typesafe:config:$typesafeVersion")
implementation("org.jetbrains.kotlinx:kotlinx-datetime:$datetimeVersion")
implementation("io.prometheus:simpleclient:$prometheusVersion")
implementation("io.ktor:ktor-client-jvm:$ktorVersion")
implementation("io.ktor:ktor-client-cio-jvm:$ktorVersion")
implementation("io.ktor:ktor-client-auth-jvm:$ktorVersion")
implementation("io.ktor:ktor-network-jvm:$ktorVersion")
implementation("io.ktor:ktor-network-tls-jvm:$ktorVersion")
implementation("io.ktor:ktor-server-jvm:$ktorVersion")
implementation("io.ktor:ktor-server-cio-jvm:$ktorVersion")
implementation("io.ktor:ktor-server-call-logging:$ktorVersion")
implementation("io.ktor:ktor-server-compression:$ktorVersion")
implementation("io.dropwizard.metrics:metrics-healthchecks:$dropwizardVersion")
implementation("io.zipkin.brave:brave-instrumentation-grpc:$zipkinVersion")
implementation("io.github.oshai:kotlin-logging-jvm:$loggingVersion")
implementation("ch.qos.logback:logback-classic:$logbackVersion")
implementation("org.slf4j:jul-to-slf4j:$slf4jVersion")
testImplementation("org.amshove.kluent:kluent:$kluentVersion")
testImplementation("org.junit.jupiter:junit-jupiter-api:$junitVersion")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$junitVersion")
}
publishing {
publications {
create<MavenPublication>("mavenJava") {
from(components["java"])
versionMapping {
usage("java-api") {
fromResolutionOf("runtimeClasspath")
}
usage("java-runtime") {
fromResolutionResult()
}
}
}
}
}
tasks.compileKotlin {
dependsOn(":generateProto")
}
protobuf {
protoc {
artifact = "com.google.protobuf:protoc:$protocVersion"
}
plugins {
id("grpc") {
artifact = "io.grpc:protoc-gen-grpc-java:$grpcVersion"
}
id("grpckt") {
artifact = "io.grpc:protoc-gen-grpc-kotlin:$gengrpcVersion:jdk8@jar"
}
}
generateProtoTasks {
all().forEach { task ->
task.plugins {
id("grpc") // Generate Java gRPC classes
id("grpckt") // Generate Kotlin gRPC using the custom plugin from library
}
}
}
}
configurations.all {
resolutionStrategy.cacheChangingModulesFor(0, "seconds")
}
tasks.named<Jar>("jar") {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
val sourcesJar by tasks.registering(Jar::class) {
dependsOn(tasks.classes)
archiveClassifier.set("sources")
from(sourceSets.main.get().allSource)
}
val javadocJar by tasks.registering(Jar::class) {
dependsOn(tasks.javadoc)
archiveClassifier.set("javadoc")
from(tasks.javadoc.get().destinationDir)
}
artifacts {
archives(sourcesJar)
//archives(javadocJar)
}
java {
withSourcesJar()
}
detekt {
buildUponDefaultConfig = true
allRules = false
config.setFrom("$projectDir/config/detekt/detekt.yml")
baseline = file("$projectDir/config/detekt/baseline.xml")
}
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
}
// Required for multiple uberjar targets
tasks.shadowJar {
mergeServiceFiles()
}
val agentJar by tasks.registering(Jar::class) {
dependsOn(tasks.shadowJar)
archiveFileName.set("prometheus-agent.jar")
manifest {
attributes("Main-Class" to "io.prometheus.Agent")
}
from(zipTree(tasks.shadowJar.get().archiveFile))
}
val proxyJar by tasks.registering(Jar::class) {
dependsOn(tasks.shadowJar)
archiveFileName.set("prometheus-proxy.jar")
manifest {
attributes("Main-Class" to "io.prometheus.Proxy")
}
from(zipTree(tasks.shadowJar.get().archiveFile))
}
tasks.compileKotlin {
dependsOn(":generateProto")
}
kotlin {
jvmToolchain(11)
}
tasks.withType<KotlinCompile> {
compilerOptions {
freeCompilerArgs = listOf(
"-Xbackend-threads=8",
"-opt-in=kotlin.time.ExperimentalTime",
"-opt-in=kotlin.contracts.ExperimentalContracts",
"-opt-in=kotlin.ExperimentalUnsignedTypes",
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
"-opt-in=kotlinx.coroutines.InternalCoroutinesApi",
"-opt-in=kotlinx.coroutines.DelicateCoroutinesApi",
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi"
)
}
}
tasks.withType<Test> {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed", "standardOut", "standardError")
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
showStandardStreams = true
}
}
// This will keep generated code out of the kotlinter checks
//tasks.named("lintKotlinMain") {
// source = source - fileTree("$buildDir/generated")
//}
//kotlinter {
// ignoreFailures = false
// reporters = ['checkstyle', 'plain']
//}