-
-
Notifications
You must be signed in to change notification settings - Fork 249
Expand file tree
/
Copy pathbuild.gradle
More file actions
402 lines (363 loc) · 16.9 KB
/
Copy pathbuild.gradle
File metadata and controls
402 lines (363 loc) · 16.9 KB
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
import net.ltgt.gradle.errorprone.CheckSeverity
import org.gradle.testing.jacoco.tasks.JacocoReport
import org.jetbrains.kotlin.gradle.dsl.jvm.JvmTargetValidationMode
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile
buildscript {
ext.kotlin_version = '2.4.10'
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
mavenCentral()
}
dependencies {
classpath "gradle.plugin.org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.12.2"
classpath 'net.researchgate:gradle-release:3.1.0'
classpath "com.github.ben-manes:gradle-versions-plugin:0.54.0"
classpath "com.gradleup.shadow:shadow-gradle-plugin:9.6.1"
classpath "com.diffplug.spotless:spotless-plugin-gradle:8.10.0"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.graalvm.buildtools:native-gradle-plugin:1.1.10"
classpath "com.vanniktech:gradle-maven-publish-plugin:0.37.0"
classpath "info.solidsoft.gradle.pitest:gradle-pitest-plugin:1.19.0"
classpath "net.ltgt.gradle:gradle-errorprone-plugin:5.1.0"
}
}
plugins {
id "org.sonarqube" version "7.4.0.8496"
}
sonarqube {
properties {
property "sonar.projectKey", "sirixdb_sirix"
property "sonar.organization", "sirixdb"
property "sonar.host.url", "https://sonarcloud.io"
}
}
apply from: "${rootDir}/libraries.gradle"
apply plugin: 'net.researchgate.release'
release {
failOnSnapshotDependencies = false
failOnUnversionedFiles = false
tagTemplate = 'sirix-$version'
buildTasks = ['releaseBuild']
}
task releaseBuild {
project.afterEvaluate {
dependsOn project.getTasksByName('build', true)
}
}
task travisReleaseSnapshot {
if ("${version}".endsWith('SNAPSHOT')) {
project.afterEvaluate {
dependsOn project.getTasksByName('publishAllPublicationsToMavenRepository', true)
}
}
}
// Release publishing is handled by CI workflow on tag push
// afterReleaseBuild.dependsOn(uploadPublications)
allprojects {
group = 'io.sirix'
apply plugin: 'com.github.kt3k.coveralls'
apply plugin: 'idea'
repositories {
mavenLocal() // Check local Maven repository first for SNAPSHOT versions
mavenCentral()
maven {
url = "https://central.sonatype.com/repository/maven-snapshots/"
}
}
// brackit is developed alongside sirix and is consumed as a moving SNAPSHOT, so Gradle's
// default of trusting a cached changing module for 24 hours resolves a version of it that no
// longer exists anywhere. That failure is silent and asymmetric: one lane passing
// --refresh-dependencies compiles against today's brackit while every other lane compiles
// against yesterday's, and the error surfaces as a missing symbol rather than a stale cache.
configurations.configureEach {
resolutionStrategy {
cacheChangingModulesFor 0, 'seconds'
cacheDynamicVersionsFor 0, 'seconds'
}
}
}
subprojects {
apply plugin: 'java'
apply plugin: 'java-library'
apply plugin: 'com.vanniktech.maven.publish'
apply plugin: 'com.github.ben-manes.versions'
// Shadow plugin applied selectively in subprojects that need it
apply plugin: "com.diffplug.spotless"
apply plugin: 'jacoco'
jacoco {
// Needs to understand Java 25 class files; the plugin's bundled default lags the toolchain.
toolVersion = '0.8.13'
}
// Instrument only when coverage is actually going to be consumed. The agent rewrites every
// loaded class and adds a probe write per branch, which taxes every `gradlew test` run.
//
// The trigger is the TASK GRAPH, not just -Pcoverage: sonarqube.yml runs `gradlew build
// sonarqube` without any flag, and gating on the flag alone would have left Sonar silently
// reporting 0% coverage with no failing task to notice it. Enabling whenever a Jacoco report
// (or Sonar) is in the graph keeps CI honest and still leaves a bare `gradlew test`
// uninstrumented.
gradle.taskGraph.whenReady { graph ->
final boolean coverageWanted = project.hasProperty('coverage') || graph.allTasks.any {
it instanceof JacocoReport || it.name.toLowerCase().startsWith('sonar')
}
tasks.withType(Test).configureEach {
jacoco.enabled = coverageWanted
}
}
tasks.named('jacocoTestReport') {
dependsOn tasks.named('test')
reports {
xml.required = true
html.required = true
}
// The generated/vendored trees say nothing about this project's own coverage. Filtered
// lazily: resolving classDirectories.files here would flatten a live FileCollection into a
// plain file list, dropping its builtBy wiring to `classes` (and breaking the configuration
// cache) — which is what made the explicit dependsOn above necessary in the first place.
classDirectories.setFrom(sourceSets.main.output.classesDirs.asFileTree.matching {
exclude '**/generated/**'
})
}
tasks.withType(KotlinJvmCompile).configureEach {
jvmTargetValidationMode.set(JvmTargetValidationMode.WARNING)
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(25)
}
sourceCompatibility = JavaVersion.VERSION_25
targetCompatibility = JavaVersion.VERSION_25
}
javadoc {
failOnError = false
options {
addStringOption('-release', '25')
addBooleanOption('-enable-preview', true)
}
}
compileJava {
options.compilerArgs += ["--enable-preview",
"--add-modules=jdk.incubator.vector",
"--add-exports=java.base/jdk.internal.ref=ALL-UNNAMED",
"--add-exports=java.base/sun.nio.ch=ALL-UNNAMED",
"--add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
"--add-exports=java.base/java.lang.reflect=ALL-UNNAMED"
]
}
compileTestJava {
options.compilerArgs += ["--enable-preview",
"--add-modules=jdk.incubator.vector",
"--add-exports=java.base/jdk.internal.ref=ALL-UNNAMED",
"--add-exports=java.base/sun.nio.ch=ALL-UNNAMED",
"--add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
"--add-exports=java.base/java.lang.reflect=ALL-UNNAMED"]
}
// ═══════════════════════════════════════════════════════════════════════
// Error Prone + NullAway — opt-in static bug detection:
// ./gradlew compileJava -PerrorProne (all modules)
// ./gradlew :sirix-core:compileJava -PerrorProne
// Off by default so the everyday build is unchanged; the verification CI
// workflow runs it. ERROR-severity Error Prone checks (almost-always-real
// bugs: bad equals/hashCode, format strings, self-assignment, ...) fail the
// compile; NullAway reports nullness-contract violations as warnings.
// ═══════════════════════════════════════════════════════════════════════
if (project.hasProperty('errorProne')) {
apply plugin: 'net.ltgt.errorprone'
dependencies {
errorprone "com.google.errorprone:error_prone_core:2.50.0"
errorprone "com.uber.nullaway:nullaway:0.14.0"
}
tasks.withType(JavaCompile).configureEach {
options.errorprone {
disableWarningsInGeneratedCode = true
excludedPaths = '.*/build/generated/.*'
option('NullAway:AnnotatedPackages', 'io.sirix')
check('NullAway', CheckSeverity.WARN)
// Nodes/pages deliberately compare MemorySegments by reference: the question is
// "is this node backed by exactly this segment instance", not value equality —
// and identity is the cheap check on the hot path. Keep as a warning.
check('MemorySegmentReferenceEquality', CheckSeverity.WARN)
}
}
}
spotless {
// One rule, generally enforced: the sirix formatter profile. Ratcheting scopes the
// check to files changed since main, so legacy formatting debt never blocks a build
// and no repo-wide reformat is required.
ratchetFrom 'origin/main'
java {
targetExclude "**/index/art/Abstract*Test.java",
"**/index/art/NavigableKeySetStringTest.java",
"**/index/art/acc/**"
eclipse().configFile("${rootDir}/eclipse/sirix-formatter.xml")
}
}
mavenPublishing {
// SonatypeHost was removed in gradle-maven-publish-plugin 0.34.0; the Central
// Portal is the only supported host and automatic release is the boolean arg.
publishToMavenCentral(true)
signAllPublications()
pom {
name = "${project.name}"
description = "${project.description}"
url = "https://sirix.io"
licenses {
license {
name = "New BSD"
url = "http://www.opensource.org/licenses/bsd-license.php"
comments = "3-clause BSD License"
}
}
scm {
connection = "scm:git:git@github.com:sirixdb/sirix.git"
developerConnection = "scm:git:git@github.com:sirixdb/sirix.git"
url = "https://github.com/sirixdb/sirix"
}
issueManagement {
url = "https://github.com/sirixdb/sirix/issues"
system = "GitHub Issues"
}
ciManagement {
system = "GitHub Actions"
url = "https://github.com/sirixdb/sirix/actions"
}
developers {
developer {
id = "johanneslichtenberger"
name = "Johannes Lichtenberger"
email = "johannes.lichtenberger@sirix.io"
}
}
}
}
signing {
useGpgCmd()
}
configurations {
testArtifacts.extendsFrom testImplementation
}
task testsJar(type: Jar) {
archiveClassifier = 'tests'
zip64 = true
from(sourceSets.test.output)
}
artifacts {
testArtifacts testsJar
}
jar {
into("META-INF/maven/io.sirix/$project.name") {
from { generatePomFileForMavenPublication }
rename ".*", "pom.xml"
}
}
tasks.withType(JavaCompile).tap {
configureEach {
options.encoding = 'UTF-8'
}
}
test {
testLogging {
events "failed"
exceptionFormat "short"
// Opt-in only: the forked JVM's stdout/stderr is the only way to read the
// -Dsirix.*Diag route traces, and it is far too noisy to carry by default.
if (System.getenv("SIRIX_TEST_STREAMS") != null) {
showStandardStreams = true
}
}
// Re-print every failure at the END of the run: the GitHub Actions
// log API only serves a bounded tail, so per-test failure lines from
// early in a long run are unretrievable — this summary is not.
def failedTests = []
afterTest { desc, result ->
if (result.resultType == TestResult.ResultType.FAILURE) {
failedTests << "${desc.className} > ${desc.name}: ${result.exception?.toString()?.take(400)}"
}
}
afterSuite { desc, result ->
if (desc.parent == null && !failedTests.empty) {
println "\n===== FAILED TESTS (${failedTests.size()}) ====="
failedTests.each { println "FAILED-TEST: ${it}" }
println "===== END FAILED TESTS ====="
}
}
useJUnit()
// Flags that only pay off when profiling are opt-in: every forked test JVM otherwise
// pays for them up front. Pre-touching the whole initial heap costs seconds of start-up
// per fork, and debug-level GC logging is a steady stream of synchronous file writes —
// both are pure overhead on CI, where nobody reads the output.
// SIRIX_TEST_PRETOUCH=1 -> -XX:+AlwaysPreTouch (stable timings for benchmark runs)
// SIRIX_GC_LOG=1 -> debug-level GC log in g1.log plus -verbose:gc
final boolean preTouch = System.getenv("SIRIX_TEST_PRETOUCH") != null
final boolean gcLog = System.getenv("SIRIX_GC_LOG") != null
// Large pages only ever worked on the Linux boxes: macOS has no equivalent and Windows
// needs the "Lock pages in memory" privilege, which CI runners do not grant. Elsewhere
// the flag buys a JVM warning and nothing else.
final boolean largePages = System.getProperty("os.name").toLowerCase().contains("linux")
final List<String> testJvmArgs = ["--enable-preview",
"--add-exports=java.base/jdk.internal.ref=ALL-UNNAMED",
"--add-exports=java.base/sun.nio.ch=ALL-UNNAMED",
"--add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac=ALL-UNNAMED",
"--add-opens=java.base/java.lang=ALL-UNNAMED",
"--add-opens=java.base/java.lang.reflect=ALL-UNNAMED",
"--add-opens=java.base/java.io=ALL-UNNAMED",
"--add-opens=java.base/java.util=ALL-UNNAMED",
"--add-opens=java.base/java.lang.reflect=ALL-UNNAMED",
"--enable-native-access=ALL-UNNAMED",
"-XX:+UnlockDiagnosticVMOptions",
"-XX:+DebugNonSafepoints",
//"-XX:+UseShenandoahGC",
"-XX:+UseZGC",
// "-XX:+ZGenerational",
"-XX:+HeapDumpOnOutOfMemoryError",
//"-XX:HeapDumpPath=heapdump.hprof",
"-XX:+UseStringDeduplication",
//"-XX:MaxMetaspaceSize=3g",
//"-XX:InitiatingHeapOccupancyPercent=20",
//"-XX:MaxGCPauseMillis=60",
"-XX:MaxDirectMemorySize=1g",
"-XX:+UnlockExperimentalVMOptions",
"-XX:ReservedCodeCacheSize=1000m",
"-XX:+UnlockDiagnosticVMOptions",
// "-XX:+PrintInlining",
// NOTE: the long-carried "-Ddisable.single.threaded.check=true" flag was removed:
// it is a Chronicle-Bytes property and nothing on the classpath reads it.
"-XX:EliminateAllocationArraySizeLimit=1024"
/* "-XX:MaxInlineSize=500" */]
if (preTouch) {
testJvmArgs << "-XX:+AlwaysPreTouch"
}
if (largePages) {
testJvmArgs << "-XX:+UseLargePages"
}
if (gcLog) {
testJvmArgs.addAll(["-Xlog:gc*=debug:file=g1.log", "-verbose:gc"])
}
jvmArgs(testJvmArgs)
// A 5 GB initial heap per fork is right for the 16 GB Linux runners and a workstation,
// but wrong for the cross-platform lanes: the macOS runners have 7 GB total, so the
// committed heap plus the Gradle daemon puts the machine into swap before the first
// test runs. Those lanes pass -PtestHeapMin/-PtestHeapMax to size the fork down.
minHeapSize = (project.findProperty('testHeapMin') ?: '5g').toString()
maxHeapSize = (project.findProperty('testHeapMax') ?: '12g').toString()
// Allow override via env TMPDIR for sandboxed test execution and for CI lanes that need
// the scratch files on a specific volume. Blank is treated as unset — pointing
// java.io.tmpdir at an empty string would break every temp-file-creating test.
final String tmpDirOverride = System.getenv("TMPDIR")
if (tmpDirOverride != null && !tmpDirOverride.trim().isEmpty()) {
systemProperty 'java.io.tmpdir', tmpDirOverride
}
// Forward all sirix.* system properties from the gradle JVM to the test
// JVM so command-line flags like -Dsirix.valueElision.regionLookup.enable=true
// reach the page serializer/deserializer under test.
System.properties.findAll { it.key.startsWith("sirix.") }.each { k, v ->
systemProperty k, v
}
}
}