-
Notifications
You must be signed in to change notification settings - Fork 23
/
build.gradle
345 lines (290 loc) · 12 KB
/
build.gradle
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
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
plugins {
id 'idea'
id 'java'
id 'maven-publish'
id 'org.jetbrains.kotlin.jvm' version '2.0.0'
id 'com.google.protobuf' version '0.9.4' // Keep in sync with grpc
id 'org.jmailen.kotlinter' version "4.3.0"
id "com.github.ben-manes.versions" version '0.51.0'
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'com.github.gmazzo.buildconfig' version '5.3.5'
id 'org.jetbrains.kotlinx.kover' version '0.8.1'
id 'io.gitlab.arturbosch.detekt' version '1.23.6'
// 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.22.0'
//sourceCompatibility = JavaVersion.VERSION_17
//targetCompatibility = JavaVersion.VERSION_17
buildConfig {
packageName("io.prometheus")
buildConfigField('String', 'APP_NAME', "\"${project.name}\"")
buildConfigField('String', 'APP_VERSION', "\"${project.version}\"")
buildConfigField('String', 'APP_RELEASE_DATE', "\"06/11/2024\"")
}
repositories {
google()
mavenCentral()
maven { url = 'https://jitpack.io' }
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:$serialization_version"
implementation "io.grpc:grpc-netty:$grpc_version"
implementation "io.grpc:grpc-protobuf:$grpc_version"
implementation "io.grpc:grpc-stub:$grpc_version"
implementation "io.grpc:grpc-services:$grpc_version"
implementation("com.google.protobuf:protobuf-java:$protobuf_version")
implementation("com.google.protobuf:protobuf-java-util:$protobuf_version")
implementation "io.grpc:grpc-kotlin-stub:$gengrpc_version"
implementation "io.github.mscheong01:krotoDC-core:$krotodc_version"
// Required
implementation "io.netty:netty-tcnative-boringssl-static:$tcnative_version"
implementation "com.github.pambrose.common-utils:core-utils:$utils_version"
implementation "com.github.pambrose.common-utils:corex-utils:$utils_version"
implementation "com.github.pambrose.common-utils:dropwizard-utils:$utils_version"
implementation "com.github.pambrose.common-utils:guava-utils:$utils_version"
implementation "com.github.pambrose.common-utils:grpc-utils:$utils_version"
implementation "com.github.pambrose.common-utils:jetty-utils:$utils_version"
implementation "com.github.pambrose.common-utils:ktor-client-utils:$utils_version"
implementation "com.github.pambrose.common-utils:prometheus-utils:$utils_version"
implementation "com.github.pambrose.common-utils:service-utils:$utils_version"
implementation "com.github.pambrose.common-utils:zipkin-utils:$utils_version"
implementation "org.eclipse.jetty:jetty-servlet:$jetty_version"
implementation "javax.annotation:javax.annotation-api:$annotation_version"
implementation "org.jcommander:jcommander:$jcommander_version"
implementation "com.typesafe:config:$typesafe_version"
implementation "io.prometheus:simpleclient:$prometheus_version"
implementation "io.ktor:ktor-client-jvm:$ktor_version"
implementation "io.ktor:ktor-client-cio-jvm:$ktor_version"
implementation "io.ktor:ktor-client-auth-jvm:$ktor_version"
implementation "io.ktor:ktor-network-jvm:$ktor_version"
implementation "io.ktor:ktor-network-tls-jvm:$ktor_version"
implementation "io.ktor:ktor-server-jvm:$ktor_version"
implementation "io.ktor:ktor-server-cio-jvm:$ktor_version"
implementation "io.ktor:ktor-server-call-logging:$ktor_version"
implementation "io.ktor:ktor-server-compression:$ktor_version"
implementation "io.dropwizard.metrics:metrics-healthchecks:$dropwizard_version"
implementation "io.zipkin.brave:brave-instrumentation-grpc:$zipkin_version"
implementation "io.github.oshai:kotlin-logging-jvm:$logging_version"
implementation "ch.qos.logback:logback-classic:$logback_version"
implementation "org.slf4j:jul-to-slf4j:$slf4j_version"
testImplementation "org.amshove.kluent:kluent:$kluent_version"
testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit_version"
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
versionMapping {
usage('java-api') {
fromResolutionOf('runtimeClasspath')
}
usage('java-runtime') {
fromResolutionResult()
}
}
}
}
}
compileKotlin.dependsOn ':generateProto'
protobuf {
protoc {
artifact = "com.google.protobuf:protoc:$protoc_version"
}
plugins {
grpc {
artifact = "io.grpc:protoc-gen-grpc-java:$grpc_version"
}
// Specify protoc to generate using our grpc kotlin plugin
grpckt {
artifact = "io.grpc:protoc-gen-grpc-kotlin:$gengrpc_version:jdk8@jar"
}
krotoDC {
artifact = "io.github.mscheong01:protoc-gen-krotoDC:$krotodc_version:jdk8@jar"
}
}
generateProtoTasks {
all().each { task ->
task.plugins {
grpc {} // Generate Java gRPC classes
grpckt {} // Generate Kotlin gRPC using the custom plugin from library
krotoDC {} // Generate Kotlin data classes
}
// task.builtins {
// kotlin {}
// }
}
}
}
configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
//startScripts.enabled = false
// This is to fix a bizarre gradle error related to duplicate Agent.toString() methods
project.getTasks().getByName("jar").setProperty("duplicatesStrategy", DuplicatesStrategy.INCLUDE);
tasks.register('sourcesJar', Jar) {
dependsOn classes
from sourceSets.main.allSource
archiveClassifier = 'sources'
}
tasks.register('javadocJar', Jar) {
dependsOn javadoc
archiveClassifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives sourcesJar
//archives javadocJar
}
java {
withSourcesJar()
}
detekt {
buildUponDefaultConfig = true // preconfigure defaults
allRules = false // activate all available (even unstable) rules.
config.setFrom("$projectDir/config/detekt/detekt.yml")
// point to your custom config defining rules to run, overwriting default behavior
baseline = file("$projectDir/config/detekt/baseline.xml") // a way of suppressing issues before introducing detekt
}
//tasks.withType(Detekt).configureEach {
// jvmTarget = "1.8"
//}
//tasks.withType(DetektCreateBaselineTask).configureEach {
// jvmTarget = "1.8"
//}
//jacocoTestReport {
// reports {
// xml.enabled true
// html.enabled true
// }
//
// afterEvaluate {
// getClassDirectories().setFrom(files(classDirectories.files.collect {
// fileTree(dir: it,
// excludes: [
// '**/ConfigVals*',
// 'io/prometheus/grpc/**'
// ])
// }))
// }
//}
//check.dependsOn jacocoTestReport
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
// Required for multiple uberjar targets
shadowJar {
mergeServiceFiles()
}
task agentJar(type: Jar, dependsOn: shadowJar) {
archiveFileName = 'prometheus-agent.jar'
manifest {
attributes('Main-Class': 'io.prometheus.Agent')
}
from zipTree(shadowJar.archiveFile)
}
task proxyJar(type: Jar, dependsOn: shadowJar) {
archiveFileName = 'prometheus-proxy.jar'
manifest {
attributes('Main-Class': 'io.prometheus.Proxy')
}
from zipTree(shadowJar.archiveFile)
}
compileKotlin.dependsOn ':generateProto'
kotlin {
jvmToolchain(17)
}
compileKotlin {
kotlinOptions.freeCompilerArgs += ['-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"]
}
compileTestKotlin {
kotlinOptions.freeCompilerArgs += ['-Xbackend-threads=8',
"-opt-in=kotlinx.coroutines.InternalCoroutinesApi",
"-opt-in=kotlinx.coroutines.DelicateCoroutinesApi"]
}
test {
useJUnitPlatform()
// finalizedBy jacocoTestReport
testLogging {
events "passed", "skipped", "failed", "standardOut", "standardError"
exceptionFormat "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']
}
kover {
reports {
// enable() // create Kover merged reports
//
// filters { // common filters for all default Kover merged tasks
// classes { // common class filter for all default Kover merged tasks
// includes.add("io.prometheus.*") // class inclusion rules
// //excludes.addAll("io.prometheus.subpackage.*") // class exclusion rules
// }
//
// projects { // common projects filter for all default Kover merged tasks
// //excludes.addAll("project1", ":child:project") // Specifies the projects excluded in the merged tasks
// }
// }
//
//
// xmlReport {
// onCheck.set(true)
// // true to run koverMergedXmlReport task during the execution of the check task (if it exists) of the current project
// reportFile.set(layout.buildDirectory.file("my-merged-report/result.xml")) // change report file name
// overrideClassFilter { // override common class filter
// includes.add("io.prometheus.*") // override class inclusion rules
// //excludes.addAll("io.prometheus.subpackage.*") // override class exclusion rules
// }
// }
//
// htmlReport {
// onCheck.set(true)
// // true to run koverMergedHtmlReport task during the execution of the check task (if it exists) of the current project
// reportDir.set(layout.buildDirectory.dir("my-merged-report/html-result")) // change report directory
// overrideClassFilter { // override common class filter
// includes.add("io.prometheus.*") // override class inclusion rules
// //excludes.addAll("io.prometheus.subpackage.*") // override class exclusion rules
// }
// }
// verify {
// // onCheck.set(true)
// // true to run koverMergedVerify task during the execution of the check task (if it exists) of the current project
// rule { // add verification rule
// //isEnabled = true // false to disable rule checking
// name = null // custom name for the rule
// target = 'ALL' // specify by which entity the code for separate coverage evaluation will be grouped
//
// overrideClassFilter { // override common class filter
// includes.add("io.prometheus.verify.*") // override class inclusion rules
// // excludes.addAll("io.prometheus.verify.subpackage.*") // override class exclusion rules
// }
//
// bound { // add rule bound
// minValue = 10
// maxValue = 20
// counter = 'LINE' // change coverage metric to evaluate (LINE, INSTRUCTION, BRANCH)
// valueType = 'COVERED_PERCENTAGE'
// // change counter value (COVERED_COUNT, MISSED_COUNT, COVERED_PERCENTAGE, MISSED_PERCENTAGE)
// }
// }
// }
}
}