forked from pambrose/prometheus-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
322 lines (268 loc) · 10.8 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
plugins {
id 'idea'
id 'java'
id 'maven-publish'
id 'org.jetbrains.kotlin.jvm' version '1.7.21'
id 'com.google.protobuf' version '0.8.18' // Keep in sync with grpc
id 'org.jmailen.kotlinter' version "3.12.0"
id "com.github.ben-manes.versions" version '0.44.0'
id 'com.github.johnrengelman.shadow' version '7.1.2'
id 'com.github.gmazzo.buildconfig' version '3.1.0'
id 'org.jetbrains.kotlinx.kover' version '0.6.1'
// 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.14.2'
sourceCompatibility = 11
targetCompatibility = 11
repositories {
//maven { url "https://maven.pkg.jetbrains.space/public/p/ktor/eap" }
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 "io.grpc:grpc-kotlin-stub:$gengrpc_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 "com.beust:jcommander:$jcommander_version"
implementation "com.typesafe:config:$typesafe_version"
implementation "io.prometheus:simpleclient:$prometheus_version"
implementation "io.ktor:ktor-client:$ktor_version"
implementation "io.ktor:ktor-client-cio:$ktor_version"
implementation "io.ktor:ktor-client-auth:$ktor_version"
implementation "io.ktor:ktor-network:$ktor_version"
implementation "io.ktor:ktor-network-tls:$ktor_version"
implementation "io.ktor:ktor-server:$ktor_version"
implementation "io.ktor:ktor-server-cio:$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.microutils:kotlin-logging:$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"
}
buildConfig {
packageName("io.prometheus")
buildConfigField('String', 'APP_NAME', "\"${project.name}\"")
buildConfigField('String', 'APP_VERSION', "\"${project.version}\"")
buildConfigField('String', 'APP_RELEASE_DATE', "\"11/26/22\"")
}
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"
}
}
generateProtoTasks {
all().each { task ->
task.plugins {
grpc {} // Generate Java gRPC classes
grpckt {} // Generate Kotlin gRPC using the custom plugin from library
}
// task.builtins {
// kotlin {}
// }
}
}
}
configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
//startScripts.enabled = false
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
// This is to fix a bizarre gradle error related to duplicate Agent.toString() methods
project.getTasks().getByName("jar").setProperty("duplicatesStrategy", DuplicatesStrategy.INCLUDE);
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives sourcesJar
//archives javadocJar
}
java {
withSourcesJar()
}
//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'
compileKotlin {
kotlinOptions {
jvmTarget = "11"
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"]
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "11"
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
}
}
kotlinter {
ignoreFailures = false
//indentSize = 2
reporters = ['checkstyle', 'plain']
experimentalRules = false
disabledRules = ["no-wildcard-imports",
"indent",
"final-newline",
"comment-spacing",
"max-line-length",
"no-multi-spaces",
"no-trailing-spaces",
"wrapping",
"multiline-if-else",]
}
koverMerged {
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)
}
}
}
}