-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathbuild.gradle
267 lines (219 loc) · 9.08 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
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
plugins {
id "org.springframework.boot" version "${springBootVersion}"
id "com.palantir.docker" version "${palantirDockerVersion}"
id "org.cyclonedx.bom" version "${cyclonedxBomVersion}"
id "io.spring.dependency-management" version "${springDependencyManangementVersion}"
id "org.owasp.dependencycheck" version "${owaspDependencyCheckVersion}"
id "com.github.ben-manes.versions" version "${versionsPlugin}"
}
repositories {
mavenCentral()
}
apply plugin: "java"
apply plugin: "jacoco"
group = "rocks.inspectit.ocelot"
java {
sourceCompatibility = "17"
targetCompatibility = "17"
}
if (!project.hasProperty("buildVersion") || project.getProperty("buildVersion").empty) {
ext.buildVersion = "SNAPSHOT"
}
version = "$buildVersion"
tasks.register('downloadBoomerangjs') {
logger.info("Downloading Boomerangjs version {}.", boomerangVersion)
ext.dest = new File(buildDir, "boomerang-source-${boomerangVersion}.tgz")
outputs.files(ext.dest)
doLast {
def f = ext.dest
new URL("https://registry.npmjs.org/boomerangjs/-/boomerangjs-${boomerangVersion}.tgz")
.withInputStream { i -> f.withOutputStream { it << i } }
}
}
tasks.register('deleteBoomerangjs', Delete) {
delete new File(project.buildDir, "boomerangjs-${boomerangVersion}")
}
tasks.register ('downloadAndExtractBoomerang', Copy) {
dependsOn deleteBoomerangjs, downloadBoomerangjs
from tarTree(downloadBoomerangjs.dest)
into new File(project.buildDir, "boomerangjs-${boomerangVersion}")
filter { line -> line.replaceAll("%boomerang_version%", "${boomerangVersion}") }
}
tasks.register('generateVersionFile') {
ext.versionFile = new File(project.buildDir, "eum-version.info")
doLast {
def currentDate = new Date().toString()
ext.versionFile.withWriter("UTF-8") { writer ->
writer << "$version\n$currentDate\n$boomerangVersion"
}
}
}
tasks.register('downloadOpenTelemetryPlugin') {
ext.dest = new File(buildDir, "boomerangjs-${boomerangVersion}/package/plugins/boomerang-opentelemetry.js")
outputs.files(ext.dest)
doLast {
def f = ext.dest
new URL("https://github.com/NovatecConsulting/boomerang-opentelemetry-plugin/releases/download/$boomerangOpenTelemetryPluginVersion/boomerang-opentelemetry.js")
.withInputStream { i -> f.withOutputStream { it << i } }
}
}
bootJar {
dependsOn generateVersionFile
dependsOn downloadAndExtractBoomerang
dependsOn downloadOpenTelemetryPlugin
archiveVersion = "${buildVersion}"
base {
archivesName = "inspectit-ocelot-eum-server"
}
manifest {
attributes "Start-Class": "rocks.inspectit.oce.eum.server.EUMServerApplication"
}
// include version file
from generateVersionFile.versionFile
// include boomerang
from(layout.buildDirectory.dir("boomerangjs-${boomerangVersion}/package")) {
include "plugins/*.js"
include "boomerang.js"
into "static/boomerang"
}
//include boomerang opentelemetry
from(layout.buildDirectory) {
include "boomerang-opentelemetry.js"
into "static/boomerang"
}
}
cyclonedxBom {
includeConfigs = ["runtimeClasspath"]
schemaVersion = "1.4"
projectType = "application"
outputName = "bom"
outputFormat = "all"
}
test {
useJUnitPlatform()
testLogging {
exceptionFormat = "full"
}
}
dependencies {
implementation(
"org.springframework.boot:spring-boot-starter-web",
"org.springframework.boot:spring-boot-starter-actuator",
"org.springframework.boot:spring-boot-starter-validation",
"org.springframework.boot:spring-boot-starter-security",
"org.yaml:snakeyaml:${snakeYamlVersion}",
// Has to be included, but is transitive to spring
"com.fasterxml.jackson.dataformat:jackson-dataformat-yaml",
// pin Prometheus client to 0.6.0 to prevent auto prefixing counter metrics with "_total"
// see: https://github.com/prometheus/client_java/issues/640, https://github.com/prometheus/client_java/pull/653
"io.prometheus:simpleclient:${prometheusClientVersion}",
"io.prometheus:simpleclient_common:${prometheusClientVersion}",
"io.prometheus:simpleclient_httpserver:${prometheusClientVersion}",
"io.opencensus:opencensus-api:${openCensusVersion}",
"io.opencensus:opencensus-impl:${openCensusVersion}",
"io.opencensus:opencensus-exporter-stats-prometheus:${openCensusVersion}",
"rocks.inspectit:opencensus-influxdb-exporter:${openCensusInfluxdbExporterVersion}",
"io.grpc:grpc-context:${grpcVersion}",
platform("io.opentelemetry:opentelemetry-bom-alpha:${openTelemetryAlphaVersion}"),
platform("io.opentelemetry:opentelemetry-bom:${openTelemetryVersion}"),
"io.opentelemetry:opentelemetry-sdk:${openTelemetryVersion}",
"io.opentelemetry:opentelemetry-exporter-otlp:${openTelemetryVersion}",
"io.opentelemetry:opentelemetry-semconv:${openTelemetrySemConvVersion}",
"io.opentelemetry.proto:opentelemetry-proto:${openTelemetryProtoVersion}",
"com.google.protobuf:protobuf-java:${protobufVersion}",
"com.google.protobuf:protobuf-java-util:${protobufVersion}",
"com.google.guava:guava:${guavaVersion}",
"com.maxmind.geoip2:geoip2:${geoip2Version}",
"commons-net:commons-net:${commonsNetVersion}",
"org.apache.commons:commons-lang3:${commonsLang3Version}",
"org.apache.commons:commons-math3:${commonsMath3Version}",
"commons-io:commons-io:${commonsIoVersion}",
"org.influxdb:influxdb-java:${influxdbJavaVersion}",
)
compileOnly "org.projectlombok:lombok:${lombokVersion}"
annotationProcessor "org.projectlombok:lombok:${lombokVersion}"
testImplementation(
"org.springframework.boot:spring-boot-starter-test",
"io.opencensus:opencensus-impl:${openCensusVersion}",
"org.apache.httpcomponents:httpclient:${httpClientVersion}",
// ServerExtension
"com.linecorp.armeria:armeria-junit5:${armeriaVersion}",
"com.linecorp.armeria:armeria-grpc-protocol:${armeriaVersion}",
// for docker test containers
"org.testcontainers:testcontainers:${testContainersVersion}",
"org.testcontainers:junit-jupiter:${testContainersVersion}"
)
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine"
}
tasks.register('copyServerJar', Copy) {
dependsOn bootJar
from(layout.buildDirectory.file("libs/inspectit-ocelot-eum-server-${version}.jar"))
into(layout.buildDirectory.dir("docker-jar"))
rename("inspectit-ocelot-eum-server-${version}\\.jar",
"inspectit-ocelot-eum-server.jar")
}
docker {
dependsOn copyServerJar
name "inspectit/inspectit-ocelot-eum-server"
tags "${version}"
dockerfile file("docker/Dockerfile")
files "docker/entrypoint.sh", copyServerJar.outputs
}
dependencyCheck {
failBuildOnCVSS = 6
suppressionFile = "dependencyCheckSuppression.xml"
analyzers {
assemblyEnabled = false
ossIndex {
enabled = true
}
}
nvd {
apiKey = System.getenv("NVD_API_TOKEN")
delay = 10000
}
}
def isNonStable = { String candidate ->
def stableKeyword = ['RELEASE', 'FINAL', 'GA', 'JRE'].any { it -> candidate.toUpperCase().contains(it) }
def versionRegex = /^[0-9,.v-]+(-r)?$/
return !stableKeyword && !(candidate ==~ versionRegex)
}
def isNotSameMajorMinor = { String current, String candidate, boolean matchMinor ->
if(current.equals(candidate)) return false
def firstDot = current.indexOf('.')
def secondDot = current.indexOf('.', firstDot + 1)
def major = current.substring(0, firstDot)
def minor = current.substring(firstDot + 1, secondDot)
def majorRegex = /^$major\..*/
def minorRegex = /^$major\.${minor}\..*/
return !((candidate ==~ majorRegex) && (!matchMinor || (candidate ==~ minorRegex)))
}
tasks.named("dependencyUpdates").configure {
rejectVersionIf {
// only patch updates
isNonStable(it.candidate.version) || isNotSameMajorMinor(it.currentVersion, it.candidate.version, true)
}
}
tasks.register('dependencyUpdatesMinor', DependencyUpdatesTask) {
rejectVersionIf {
// only minor updates
isNonStable(it.candidate.version) || isNotSameMajorMinor(it.currentVersion, it.candidate.version, false)
}
}
tasks.register('dependencyUpdatesMajor', DependencyUpdatesTask) {
rejectVersionIf {
// all updates including major updates
isNonStable(it.candidate.version)
}
}
tasks.withType(DependencyUpdatesTask).configureEach {
// default settings
revision = 'milestone'
gradleReleaseChannel = "current"
checkConstraints = true
checkBuildEnvironmentConstraints = true
outputFormatter = 'json,plain'
outputDir = 'build/reports'
reportfileName = 'dependencyUpdates'
}