-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
152 lines (133 loc) · 5.18 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
152 lines (133 loc) · 5.18 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
plugins {
id("java-library")
id("checkstyle")
id("com.diffplug.spotless") version "6.25.0"
}
group = "net.ztrust.netcode"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
// ---------------------------------------------------------------------------
// Java toolchain
// ---------------------------------------------------------------------------
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
// ---------------------------------------------------------------------------
// Source sets
// ---------------------------------------------------------------------------
val integrationTest by sourceSets.creating {
compileClasspath += sourceSets.main.get().output
runtimeClasspath += sourceSets.main.get().output
}
val jmh by sourceSets.creating {
java.srcDirs("src/jmh/java")
compileClasspath += sourceSets.main.get().output
runtimeClasspath += sourceSets.main.get().output
}
// ---------------------------------------------------------------------------
// Configurations
// ---------------------------------------------------------------------------
configurations {
named(integrationTest.implementationConfigurationName) {
extendsFrom(configurations.testImplementation.get())
}
named(integrationTest.runtimeOnlyConfigurationName) {
extendsFrom(configurations.testRuntimeOnly.get())
}
named(jmh.implementationConfigurationName) {
extendsFrom(configurations.implementation.get())
}
}
// ---------------------------------------------------------------------------
// Dependencies
// ---------------------------------------------------------------------------
dependencies {
// Core library dependencies
implementation("org.agrona:agrona:1.21.2")
implementation("com.lmax:disruptor:4.0.0")
implementation("org.bouncycastle:bcprov-jdk18on:1.78.1")
implementation("net.openhft:affinity:3.23.3")
implementation("org.hdrhistogram:HdrHistogram:2.2.2")
// Unit tests
testImplementation(platform("org.junit:junit-bom:5.10.0"))
testImplementation("org.junit.jupiter:junit-jupiter")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
// Integration tests inherit testImplementation via configuration extension
add(integrationTest.implementationConfigurationName, sourceSets.main.get().output)
// JMH benchmarks
add(jmh.implementationConfigurationName, "org.openjdk.jmh:jmh-core:1.37")
add("jmhAnnotationProcessor", "org.openjdk.jmh:jmh-generator-annprocess:1.37")
}
// ---------------------------------------------------------------------------
// Compile options
// ---------------------------------------------------------------------------
tasks.withType<JavaCompile>().configureEach {
options.encoding = "UTF-8"
options.release = 21
}
// Promote all warnings to errors on production and test source sets.
// JMH source set is excluded because the annotation-processor generated
// runner code may produce warnings we cannot control.
listOf("compileJava", "compileTestJava", "compileIntegrationTestJava").forEach { taskName ->
tasks.named<JavaCompile>(taskName) {
options.compilerArgs.add("-Werror")
}
}
// Wire up JMH annotation processor so @Benchmark runner code is generated.
tasks.named<JavaCompile>("compileJmhJava") {
options.annotationProcessorPath = configurations["jmhAnnotationProcessor"]
}
// ---------------------------------------------------------------------------
// Test tasks
// ---------------------------------------------------------------------------
tasks.test {
useJUnitPlatform()
}
tasks.register<Test>("integrationTest") {
description = "Runs integration tests."
group = "verification"
testClassesDirs = integrationTest.output.classesDirs
classpath = integrationTest.runtimeClasspath
useJUnitPlatform()
shouldRunAfter(tasks.test)
}
// ---------------------------------------------------------------------------
// JMH task
// ---------------------------------------------------------------------------
tasks.register<JavaExec>("jmh") {
group = "benchmark"
description = "Runs JMH benchmarks."
dependsOn(tasks.named(jmh.classesTaskName))
classpath = jmh.runtimeClasspath
mainClass.set("org.openjdk.jmh.Main")
val quickBench = project.hasProperty("quickBench")
val resultsFile = layout.buildDirectory.get().asFile.absolutePath + "/jmh-results.json"
if (quickBench) {
args("-wi", "1", "-i", "1", "-f", "1", "-rff", resultsFile, "-rf", "json")
} else {
args("-wi", "3", "-i", "5", "-f", "2", "-rff", resultsFile, "-rf", "json")
}
}
// ---------------------------------------------------------------------------
// Checkstyle
// ---------------------------------------------------------------------------
checkstyle {
toolVersion = "10.17.0"
configFile = file("config/checkstyle/checkstyle.xml")
isIgnoreFailures = false
}
// ---------------------------------------------------------------------------
// Spotless
// ---------------------------------------------------------------------------
spotless {
java {
target("src/**/*.java")
googleJavaFormat("1.22.0")
trimTrailingWhitespace()
endWithNewline()
}
}