-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathbuild.gradle
418 lines (339 loc) · 12.6 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
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
/*
* Copyright 2021 Aiven Oy
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
buildscript {
repositories {
mavenCentral()
}
}
plugins {
id 'info.solidsoft.pitest' version '1.15.0' apply false
id "java-library"
id "distribution"
}
apply plugin: 'info.solidsoft.pitest.aggregator'
wrapper {
distributionType = 'ALL'
doLast {
def sha256Sum = new String(new URL("${distributionUrl}.sha256").bytes)
propertiesFile << "distributionSha256Sum=${sha256Sum}\n"
println "Added checksum to wrapper properties"
}
}
repositories {
mavenCentral()
}
subprojects {
// https://docs.gradle.org/current/userguide/java_library_plugin.html
apply plugin: "java"
// https://docs.gradle.org/current/userguide/checkstyle_plugin.html
apply plugin: "checkstyle"
// https://docs.gradle.org/current/userguide/jacoco_plugin.html
apply plugin: "jacoco"
// https://docs.gradle.org/current/userguide/distribution_plugin.html
apply plugin: "distribution"
apply plugin: "idea"
apply plugin: 'info.solidsoft.pitest'
apply plugin: "maven-publish"
apply plugin: "signing"
repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
flatDir {
dirs rootProject.file('lib')
}
}
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
withJavadocJar()
withSourcesJar()
}
checkstyle {
toolVersion = "10.12.0"
configDirectory = rootProject.file("checkstyle/")
}
pitest {
//adds dependency to org.pitest:pitest-junit5-plugin and sets "testPlugin" to "junit5"
junit5PluginVersion = '1.2.0'
pitestVersion = '1.16.3'
targetClasses.add("io.aiven.kafka.tieredstorage.*") //by default "${project.group}.*"
targetTests.add("io.aiven.kafka.tieredstorage.*") //by default "${project.group}.*"
threads = Runtime.getRuntime().availableProcessors()
outputFormats.addAll('XML', 'HTML')
mutators.add('ALL')
exportLineCoverage = true
if (project.name in ['storage']) {
failWhenNoMutations = false
}
}
ext {
// Keep empty lines between versions to avoid conflicts on mass update (e.g. Dependabot).
junitVersion = "5.12.0"
junitPlatformVersion = "1.12.0"
mockitoVersion = "5.15.2"
slf4jVersion = "1.7.36"
kafkaVersion = "3.6.0"
assertJVersion = "3.27.3"
apacheCommonsIOVersion = "2.18.0"
jacksonVersion = "2.18.3"
awaitilityVersion = "4.3.0"
awsSdkVersion = "2.31.13"
gcpSdkVersion = "2.45.0"
azureSdkVersion = "1.2.28"
testcontainersVersion = "1.20.6"
testcontainersFakeGcsServerVersion = "0.2.0"
bucket4jVersion = "8.14.0"
}
dependencies {
compileOnly "org.apache.kafka:kafka-clients:$kafkaVersion"
compileOnly "org.apache.kafka:kafka-storage-api:$kafkaVersion"
compileOnly "org.slf4j:slf4j-api:$slf4jVersion"
testImplementation "org.apache.kafka:kafka-clients:$kafkaVersion"
testImplementation "org.apache.kafka:kafka-storage-api:$kafkaVersion"
testImplementation "org.junit.jupiter:junit-jupiter-api:$junitVersion"
testImplementation "org.junit.jupiter:junit-jupiter-params:$junitVersion"
testImplementation 'org.junit.platform:junit-platform-launcher:$junitPlatformVersion'
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitVersion"
testImplementation "org.assertj:assertj-core:$assertJVersion"
testImplementation "org.mockito:mockito-core:$mockitoVersion"
testImplementation "org.mockito:mockito-junit-jupiter:$mockitoVersion"
testImplementation "org.awaitility:awaitility:$awaitilityVersion"
testRuntimeOnly "org.slf4j:slf4j-log4j12:$slf4jVersion"
}
tasks.named('test') {
// Use junit platform for unit tests.
useJUnitPlatform()
}
sourceSets {
integrationTest {
java {
srcDirs = ['src/integration-test/java']
}
resources {
srcDirs = ['src/integration-test/resources']
}
compileClasspath += sourceSets.main.output + configurations.testRuntimeClasspath
runtimeClasspath += output + compileClasspath
}
}
idea {
module {
testSourceDirs += sourceSets.integrationTest.java.srcDirs
testSourceDirs += sourceSets.integrationTest.resources.srcDirs
}
}
configurations {
integrationTestImplementation.extendsFrom testImplementation
integrationTestRuntime.extendsFrom testRuntimeClasspath
}
tasks.register('integrationTest', Test) {
description = 'Runs the integration tests.'
group = 'verification'
testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath = sourceSets.integrationTest.runtimeClasspath
shouldRunAfter test, distTar
useJUnitPlatform()
// Run always.
outputs.upToDateWhen { false }
}
check.configure {
dependsOn tasks.named("integrationTest")
}
tasks.javadoc {
// disable missing javadoc lint and show only warning and error messages
options.addStringOption('Xdoclint:all,-missing', '-quiet')
}
distributions {
main {
contents {
from jar
from sourcesJar
from configurations.runtimeClasspath
}
}
}
tasks.distTar {
compression = Compression.GZIP
duplicatesStrategy DuplicatesStrategy.EXCLUDE
}
publishing {
repositories {
maven {
name="sonatype"
def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots"
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
credentials(PasswordCredentials)
}
}
publications {
mavenJava(MavenPublication) {
from components.java
pom {
url = "https://github.com/Aiven-Open/tiered-storage-for-apache-kafka"
organization {
name = "Aiven Oy"
url = "https://aiven.io"
}
licenses {
license {
name = "Apache 2.0"
url = "http://www.apache.org/licenses/LICENSE-2.0"
distribution = "repo"
}
}
developers {
developer {
id = 'aiven'
name = 'Aiven Opensource'
email = '[email protected]'
}
}
scm {
connection = 'scm:git:git://github.com:Aiven-Open/tiered-storage-for-apache-kafka.git'
developerConnection = 'scm:git:ssh://github.com:Aiven-Open/tiered-storage-for-apache-kafka.git'
url = 'https://github.com/Aiven-Open/tiered-storage-for-apache-kafka'
}
}
afterEvaluate {
groupId = "io.aiven"
artifactId = "tiered-storage-for-apache-kafka-${archivesBaseName}"
}
}
}
signing {
sign publishing.publications.mavenJava
useGpgCmd()
// Some issue in the plugin:
// GPG outputs already armored signatures. The plugin also does armoring for `asc` files.
// This results in double armored signatures, i.e. garbage.
// Override the signature type provider to use unarmored output for `asc` files, which works well with GPG.
signatureTypes = new AbstractSignatureTypeProvider() {
{
BinarySignatureType binary = new BinarySignatureType() {
@Override
String getExtension() {
return "asc"
}
}
register(binary)
setDefaultType(binary.getExtension())
}
}
}
}
// Skip test fixtures from distribution archives
afterEvaluate { proj ->
// Skip test fixtures from distributions
proj.distributions.all {
contents {
// Exclude any test fixtures JARs from the distribution
exclude { element ->
element.file.name.contains('test-fixtures')
element.file.name.contains('sources')
}
}
}
}
}
distributions {
main {
contents {
from(project(":core").jar)
from(project(":core").configurations.runtimeClasspath)
from(project(":storage:core").jar)
from(project(":storage:core").configurations.runtimeClasspath)
from(project(":storage:filesystem").jar)
from(project(":storage:filesystem").configurations.runtimeClasspath)
}
}
}
tasks.distTar {
compression = Compression.GZIP
duplicatesStrategy DuplicatesStrategy.EXCLUDE
}
tasks.register('copyDistFiles', Copy) {
from tarTree(tasks.distTar.outputs.files.singleFile)
into layout.buildDirectory.dir('docker')
doFirst {
delete layout.buildDirectory.dir('docker')
}
dependsOn tasks.distTar
}
tasks.register('validateDependencies') {
doLast {
def dependencyVersions = [:]
def conflictsFound = false
subprojects { subproject ->
println "Module: ${subproject.name}"
def runtimeClasspath = subproject.sourceSets.main.runtimeClasspath
runtimeClasspath.each { file ->
def fileName = file.name
def matcher = fileName =~ /(.+)-(\d+\.\d+\.\d+(-.+)?)(\..+)/
if (matcher) {
def artifactId = matcher[0][1]
def version = matcher[0][2]
if (dependencyVersions.containsKey(artifactId)) {
if (dependencyVersions[artifactId] != version) {
println "Conflict found for $artifactId: ${dependencyVersions[artifactId]} vs $version"
conflictsFound = true
}
} else {
dependencyVersions[artifactId] = version
}
}
}
}
assert !conflictsFound : "Dependency conflicts found!"
}
}
//tasks.named("check") {
// dependsOn(tasks.named("validateDependencies"))
//}
// Define the list of modules to be published
def modulesToPublish = [
':commons',
':core',
':storage:core',
':storage:filesystem',
':storage:s3',
':storage:gcs',
':storage:azure',
]
// Define and configure the publishToSonatype task
tasks.register("publishToSonatype") {
description = 'Publishes selected modules to Sonatype repository'
group = 'publishing'
dependsOn(tasks.named("distTar"))
doFirst {
println "Publishing selected modules to Sonatype..."
}
}
// Configure task dependencies after all projects are evaluated
gradle.projectsEvaluated {
tasks.named("publishToSonatype") {
modulesToPublish.each { modulePath ->
def moduleProject = modulePath == ':' ? rootProject : project(modulePath)
def taskName = "${moduleProject.path}:publish${modulePath == ':' ? 'Maven' : 'MavenJava'}PublicationToSonatypeRepository"
try {
dependsOn(taskName)
println "Added $taskName"
} catch (Exception e) {
println "Warning: Publication task not found for ${modulePath}"
}
}
}
}