-
Notifications
You must be signed in to change notification settings - Fork 4.1k
/
build.gradle
238 lines (212 loc) · 9.56 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
import com.github.spotbugs.snom.Confidence
import com.github.spotbugs.snom.Effort
import com.github.spotbugs.snom.SpotBugsTask
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
plugins {
id 'base'
id 'com.github.spotbugs' version '6.0.7'
id 'org.jetbrains.kotlin.jvm' version '2.0.0'
id 'com.google.devtools.ksp' version '2.0.0-1.0.24'
}
allprojects {
apply plugin: 'base'
apply plugin: 'java'
apply plugin: 'java-test-fixtures'
apply plugin: 'com.github.spotbugs'
apply plugin: 'org.jetbrains.kotlin.jvm'
apply plugin: 'com.google.devtools.ksp'
apply plugin: 'idea'
// By default gradle uses directory as the project name. That works very well in a single project environment but
// projects clobber each other in an environments with subprojects when projects are in directories named identically.
def sub = rootDir.relativePath(projectDir.parentFile).replace('/', '.')
group = "io.${rootProject.name}${sub.isEmpty() ? '' : ".$sub"}"
project.base.archivesName = "${project.group}-${project.name}"
// Produce reproducible archives
// (see https://docs.gradle.org/current/userguide/working_with_files.html#sec:reproducible_archives)
tasks.withType(AbstractArchiveTask).configureEach {
preserveFileTimestamps = false
reproducibleFileOrder = true
}
// Common configurations for 'assemble'.
tasks.withType(Tar).configureEach {
duplicatesStrategy DuplicatesStrategy.INCLUDE
}
tasks.withType(Zip).configureEach {
duplicatesStrategy DuplicatesStrategy.INCLUDE
// Disabling distZip causes the build to break for some reason, so: instead of disabling it, make it fast.
entryCompression ZipEntryCompression.STORED
}
// Convenience task to list all dependencies per project
tasks.register('listAllDependencies', DependencyReportTask) {}
// Common java configurations
java {
withSourcesJar()
withJavadocJar()
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
compileJava {
options.compilerArgs += ["-Werror", "-Xlint:all,-serial,-processing"]
}
compileTestJava {
//rawtypes and unchecked are necessary for mockito
//deprecation and removal are removed from error since we should still test those constructs.
options.compilerArgs += ["-Werror", "-Xlint:all,-serial,-processing,-rawtypes,-unchecked,-deprecation,-removal"]
}
compileTestFixturesJava {
//rawtypes and unchecked are necessary for mockito
options.compilerArgs += ["-Werror", "-Xlint:all,-serial,-processing,-rawtypes,-unchecked"]
}
}
tasks.named('sourcesJar').configure {
dependsOn tasks.matching { it.name == 'generate' }
}
compileKotlin {
compilerOptions {
jvmTarget = JvmTarget.JVM_21
languageVersion = KotlinVersion.KOTLIN_1_9
allWarningsAsErrors = true
freeCompilerArgs = ["-Xjvm-default=all"]
}
dependsOn {
tasks.matching { it.name == 'generate' }
}
}
compileTestKotlin {
compilerOptions {
jvmTarget = JvmTarget.JVM_21
languageVersion = KotlinVersion.KOTLIN_1_9
allWarningsAsErrors = true
freeCompilerArgs = ["-Xjvm-default=all"]
}
dependsOn {
tasks.matching { it.name == 'generate' }
}
}
compileTestFixturesKotlin {
compilerOptions {
jvmTarget = JvmTarget.JVM_21
languageVersion = KotlinVersion.KOTLIN_1_9
allWarningsAsErrors = true
freeCompilerArgs = ["-Xjvm-default=all"]
}
dependsOn {
tasks.matching { it.name == 'generate' }
}
}
configurations.all {
resolutionStrategy {
preferProjectModules()
}
}
idea {
module {
downloadJavadoc = true
downloadSources = true
}
}
spotbugs {
ignoreFailures = false
effort = Effort.valueOf('MAX')
excludeFilter.set rootProject.file('spotbugs-exclude-filter-file.xml')
reportLevel = Confidence.valueOf('HIGH')
showProgress = false
toolVersion = '4.8.3'
}
test {
useJUnitPlatform()
testLogging() {
events 'skipped', 'started', 'passed', 'failed'
exceptionFormat 'full'
// Swallow the logs when running in airbyte-ci, rely on test reports instead.
showStandardStreams = !System.getenv().containsKey("RUN_IN_AIRBYTE_CI")
}
reports {
junitXml {
outputPerTestCase = true
}
}
// This is required by mockito, see https://github.com/mockito/mockito/issues/3037.
jvmArgs "-XX:+EnableDynamicAgentLoading"
// This is also required, to prevent stderr spam starting with
// "OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader cl..."
jvmArgs "-Xshare:off"
// needed because we make ThreadLocal.get(Thread) accessible in IntegrationRunner.stopOrphanedThreads
jvmArgs "--add-opens=java.base/java.lang=ALL-UNNAMED"
// Set the timezone to UTC instead of picking up the host machine's timezone,
// which on a developer's laptop is more likely to be PST.
systemProperty 'user.timezone', 'UTC'
// Enable parallel test execution in JUnit by default.
// This is to support @Execution(ExecutionMode.CONCURRENT) annotations
// See https://junit.org/junit5/docs/current/user-guide/#writing-tests-parallel-execution for details.
systemProperty 'junit.jupiter.execution.parallel.enabled', 'true'
// Concurrency takes place at the class level.
systemProperty 'junit.jupiter.execution.parallel.mode.classes.default', 'concurrent'
// Within a class, the test methods are still run serially on the same thread.
systemProperty 'junit.jupiter.execution.parallel.mode.default', 'same_thread'
// Effectively disable JUnit concurrency by running tests in only one thread by default.
systemProperty 'junit.jupiter.execution.parallel.config.strategy', 'fixed'
systemProperty 'junit.jupiter.execution.parallel.config.fixed.parallelism', 1
// Order test classes by annotation.
systemProperty 'junit.jupiter.testclass.order.default', 'org.junit.jupiter.api.ClassOrderer$OrderAnnotation'
systemProperty 'junit.jupiter.extensions.autodetection.enabled', 'true'
if (!project.hasProperty('testExecutionConcurrency')) {
// By default, let gradle spawn as many independent workers as it wants.
maxParallelForks = Runtime.runtime.availableProcessors()
maxHeapSize = '3G'
} else {
// Otherwise, run tests within the same JVM.
// Let gradle spawn only one worker.
maxParallelForks = 1
maxHeapSize = '8G'
// Manage test execution concurrency in JUnit.
String concurrency = project.property('testExecutionConcurrency').toString()
if (concurrency.isInteger() && (concurrency as int) > 0) {
// Define a fixed number of threads when the property is set to a positive integer.
systemProperty 'junit.jupiter.execution.parallel.config.fixed.parallelism', concurrency
} else {
// Otherwise let JUnit manage the concurrency dynamically.
systemProperty 'junit.jupiter.execution.parallel.config.strategy', 'dynamic'
}
}
String junitMethodExecutionTimeout
if (project.hasProperty('JunitMethodExecutionTimeout')) {
junitMethodExecutionTimeout = project.property('JunitMethodExecutionTimeout').toString()
} else {
junitMethodExecutionTimeout = '1 m'
}
systemProperty 'JunitMethodExecutionTimeout', junitMethodExecutionTimeout
}
dependencies {
// JUnit dependencies.
def vAssertJ = "3.25.3"
def vJUnit = "5.10.2"
def vJUnitJupiter = "5.11.0"
testFixturesImplementation platform("org.junit:junit-bom:${vJUnit}")
testFixturesImplementation "org.junit.jupiter:junit-jupiter-api:${vJUnit}"
testFixturesImplementation "org.junit.jupiter:junit-jupiter-params:${vJUnit}"
testFixturesImplementation "org.mockito:mockito-junit-jupiter:${vJUnitJupiter}"
testFixturesImplementation "org.assertj:assertj-core:${vAssertJ}"
testImplementation platform("org.junit:junit-bom:${vJUnit}")
testImplementation "org.junit.jupiter:junit-jupiter-api:${vJUnit}"
testImplementation "org.junit.jupiter:junit-jupiter-params:${vJUnit}"
testImplementation "org.mockito:mockito-junit-jupiter:${vJUnitJupiter}"
testImplementation "org.assertj:assertj-core:${vAssertJ}"
testImplementation 'org.mockito.kotlin:mockito-kotlin:5.2.1'
testRuntimeOnly platform("org.junit:junit-bom:${vJUnit}")
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${vJUnit}"
// Spotbugs dependencies.
def vSpotbugs = "4.8.3"
implementation "com.github.spotbugs:spotbugs-annotations:${vSpotbugs}"
}
tasks.withType(SpotBugsTask).configureEach {
// Reports can be found under each subproject in build/spotbugs/
reports {
xml.required = false
html.required = true
}
}
javadoc {
options.addStringOption('Xdoclint:none', '-quiet')
}
}