forked from SDA-SE/mongodb-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
208 lines (182 loc) · 7.07 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
plugins {
id "jacoco"
id "idea"
id "java"
id 'org.sonarqube' version '6.0.1.5171'
id "com.diffplug.spotless" version "6.25.0"
id "com.google.cloud.tools.jib" version "3.4.4"
id 'org.cyclonedx.bom' version '1.10.0'
}
repositories {
mavenCentral()
}
group "com.sdase.k8s.operator.mongodb"
idea.module.inheritOutputDirs = true
version = System.getenv('SEMANTIC_VERSION')
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
vendor = JvmVendorSpec.ADOPTIUM
}
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
jib {
container.ports = ['8081']
container.args = []
from.image = 'gcr.io/distroless/java21-debian12:nonroot'
container.user = 10001
to.image = "$rootProject.name:latest"
container.labels = [
'org.opencontainers.image.title': rootProject.name,
'org.opencontainers.image.version': version,
'org.opencontainers.image.url': "https://github.com/SDA-SE/${rootProject.name}",
'org.opencontainers.image.source': "https://github.com/SDA-SE/${rootProject.name}",
'org.opencontainers.image.licenses': "MIT",
'org.opencontainers.image.description': "A Kubernetes Operator that creates users and databases in existing MongoDB clusters based on a custom resource.",
]
}
project.ext {
mongoDbDriverVersion = "5.2.1"
slf4jVersion = "2.0.16"
operatorFrameworkVersion = "4.9.7"
kubernetesServerMockVersion = "6.13.4" // align with transitive dependency of operator framework
mockitoVersion = "5.2.0"
jacksonVersion = "2.18.2"
logbackContribVersion = "0.1.5"
}
dependencies {
implementation enforcedPlatform("com.fasterxml.jackson:jackson-bom:${jacksonVersion}")
annotationProcessor enforcedPlatform("com.fasterxml.jackson:jackson-bom:${jacksonVersion}")
implementation enforcedPlatform('org.eclipse.jetty:jetty-bom:11.0.24')
implementation "io.javaoperatorsdk:operator-framework:${operatorFrameworkVersion}", {
// self managed to avoid conflicts
exclude group: "org.slf4j"
// recheck when operator-framework is upgraded
exclude group: 'com.squareup.okio', module: 'okio'
}
annotationProcessor "io.javaoperatorsdk:operator-framework:${operatorFrameworkVersion}", {
// self managed to avoid conflicts
exclude group: "org.slf4j"
// recheck when operator-framework is upgraded
exclude group: 'com.squareup.okio', module: 'okio'
}
// upgrade from transitive 1.15.0 in okhttp to fix CVE-2023-3635
implementation 'com.squareup.okio:okio:3.9.1'
implementation "org.mongodb:mongodb-driver-sync:${mongoDbDriverVersion}"
implementation 'org.hibernate.validator:hibernate-validator:8.0.1.Final'
implementation 'jakarta.el:jakarta.el-api:6.0.1'
implementation 'org.bouncycastle:bcpkix-jdk18on:1.79'
implementation "io.javalin:javalin:6.3.0", {
// self managed to avoid conflicts
exclude group: "org.slf4j"
// conflict with Kotlin version in Okio 3.9.0
exclude group: "org.jetbrains.kotlin", module: "kotlin-stdlib-jdk8"
}
// logging
annotationProcessor "org.slf4j:slf4j-api:${slf4jVersion}"
implementation "org.slf4j:slf4j-api:${slf4jVersion}"
implementation 'ch.qos.logback:logback-classic:1.5.12', {
exclude group: "org.slf4j", module: "slf4j-api"
}
implementation "ch.qos.logback.contrib:logback-json-classic:${logbackContribVersion}", {
exclude group: "ch.qos.logback", module: "logback-classic"
exclude group: "ch.qos.logback", module: "logback-core"
}
implementation "ch.qos.logback.contrib:logback-jackson:${logbackContribVersion}", {
exclude group: "ch.qos.logback", module: "logback-core"
}
implementation 'io.micrometer:micrometer-registry-prometheus:1.14.1'
// test
testImplementation enforcedPlatform("org.junit:junit-bom:5.11.3")
testImplementation 'org.junit.jupiter:junit-jupiter'
testImplementation 'org.junit-pioneer:junit-pioneer:2.3.0'
testImplementation 'org.assertj:assertj-core:3.26.3', {
// conflict of 1.12.10 in assertj vs 1.12.13 in mockito-core
exclude group: "net.bytebuddy", module: "byte-buddy"
exclude group: "net.bytebuddy", module: "byte-buddy-agent"
}
// try to replace local commons-compress management on update!
testImplementation 'de.flapdoodle.embed:de.flapdoodle.embed.mongo:4.18.1', {
exclude group: "org.slf4j", module: "slf4j-api"
// newer version from operator-framework
exclude group: "org.apache.commons", module: "commons-lang3"
}
testImplementation "org.mongodb:mongodb-driver-legacy:${mongoDbDriverVersion}"
testImplementation "org.mockito:mockito-junit-jupiter:${mockitoVersion}", {
// conflict of 1.14.1 and 1.14.7 in uk.org.webcompere:system-stubs-jupiter
exclude group: 'net.bytebuddy', 'module': 'byte-buddy'
exclude group: 'net.bytebuddy', 'module': 'byte-buddy-agent'
}
testImplementation "uk.org.webcompere:system-stubs-jupiter:2.1.7"
testImplementation "org.mockito:mockito-inline:${mockitoVersion}", {
// conflict of 1.14.1 and 1.14.7 in uk.org.webcompere:system-stubs-jupiter
exclude group: 'net.bytebuddy', 'module': 'byte-buddy'
exclude group: 'net.bytebuddy', 'module': 'byte-buddy-agent'
}
testImplementation 'org.awaitility:awaitility:4.2.2'
testImplementation "io.fabric8:kubernetes-server-mock:${kubernetesServerMockVersion}", {
// self managed to avoid conflicts
exclude group: "org.slf4j"
exclude group: 'com.squareup.okio', module: 'okio'
exclude group: 'junit', module: 'junit'
}
// CVE-2020-15250 in 4.12
// -> pulled transitively from OkHttp3 mockwebserver used by kubernetes-server-mock
testImplementation 'junit:junit:4.13.2'
}
dependencyLocking { lockAllConfigurations() }
// Task for creating gradle.lockfile per module. Needed for Trivy vulnerability scan.
tasks.register('resolveAndLockAll') {
doFirst {
assert gradle.startParameter.writeDependencyLocks
}
doLast {
configurations.findAll {
it.canBeResolved
}.each { it.resolve() }
}
}
test {
useJUnitPlatform()
}
spotless {
java { googleJavaFormat('1.18.1') }
enforceCheck = false
}
configurations.configureEach {
if (it.name.startsWith("spotless")) {
// Workaround for https://github.com/diffplug/spotless/issues/1965.
} else {
it.resolutionStrategy {
failOnVersionConflict()
}
}
}
// begin config for SonarCloud
jacocoTestReport {
reports {
xml.required = true
}
}
sonar {
properties {
property 'sonar.projectKey', 'SDA-SE_mongodb-operator'
property 'sonar.organization', 'sda-se'
property 'sonar.host.url', 'https://sonarcloud.io'
property 'sonar.token', System.getenv('SONAR_LOGIN_TOKEN')
property 'sonar.pullrequest.provider', 'GitHub'
property 'sonar.pullrequest.github.repository', System.getenv('GITHUB_REPOSITORY')
if (System.getenv('GITHUB_PR') != null && System.getenv('GITHUB_PR') != "") {
property 'sonar.pullrequest.key', System.getenv('GITHUB_PR')
if (System.getenv('GITHUB_BRANCH') != null) {
property 'sonar.pullrequest.branch', System.getenv('GITHUB_BRANCH')
}
}
if (System.getenv('SONAR_SCM_REVISION') != null) {
property 'sonar.scm.revision', System.getenv('SONAR_SCM_REVISION')
}
}
}
// end config for SonarCloud