-
Notifications
You must be signed in to change notification settings - Fork 44
/
build.gradle
305 lines (261 loc) · 9.01 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
/*
* Copyright 2015-2024 Real Logic Limited.
*
* 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
*
* https://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.
*/
plugins {
id 'java-library'
id 'checkstyle'
alias(libs.plugins.versions)
alias(libs.plugins.shadow).apply(false)
alias(libs.plugins.protobuf).apply(false)
}
defaultTasks 'clean', 'build'
static int getBuildJavaVersion() {
def buildJavaVersion = System.getenv('BUILD_JAVA_VERSION') ?: JavaVersion.current().getMajorVersion()
if (buildJavaVersion.indexOf('.') > 0) {
buildJavaVersion = buildJavaVersion.substring(0, buildJavaVersion.indexOf('.'))
}
if (buildJavaVersion.indexOf('-') > 0) {
buildJavaVersion = buildJavaVersion.substring(0, buildJavaVersion.indexOf('-'))
}
Integer.parseInt(buildJavaVersion)
}
int buildJavaVersion = getBuildJavaVersion()
def toolchainLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(buildJavaVersion)
}
def toolchainCompiler = javaToolchains.compilerFor {
languageVersion = JavaLanguageVersion.of(buildJavaVersion)
}
allprojects {
repositories {
mavenLocal()
mavenCentral()
}
configurations.configureEach {
resolutionStrategy {
failOnVersionConflict()
force libs.agrona,
libs.jackson.databind,
libs.slf4j.api,
libs.scala.library,
libs.scala.reflect,
libs.errorprone,
libs.checker,
"org.codehaus.plexus:plexus-utils:3.3.0",
"org.apache.commons:commons-lang3:3.8.1",
"org.apache.httpcomponents:httpcore:4.4.14",
"commons-codec:commons-codec:1.15",
"commons-io:commons-io:2.14.0",
"com.google.protobuf:protobuf-java:3.25.5"
}
}
}
subprojects {
apply plugin: 'java-library'
apply plugin: 'checkstyle'
dependencies {
testImplementation platform("org.junit:junit-bom:${libs.versions.junit.get()}")
testImplementation "org.junit.jupiter:junit-jupiter-params"
testImplementation libs.mockito
testImplementation libs.hamcrest
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine"
testRuntimeOnly "org.junit.platform:junit-platform-launcher"
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(buildJavaVersion)
}
sourceCompatibility = JavaVersion.VERSION_17
}
checkstyle.toolVersion = libs.versions.checkstyle.get()
tasks.withType(Jar).configureEach {
enabled = true
includeEmptyDirs = false
}
tasks.withType(JavaCompile).configureEach {
javaCompiler.set(toolchainCompiler)
options.compilerArgs.add('-XDignore.symbol.file') // Suppress warnings about using Unsafe
options.encoding = 'UTF-8'
options.deprecation = true
}
tasks.withType(Test).configureEach {
useJUnitPlatform()
if (buildJavaVersion >= 21) {
jvmArgs('-XX:+EnableDynamicAgentLoading')
}
testLogging {
for (def level : LogLevel.values())
{
def testLogging = get(level)
testLogging.exceptionFormat = 'full'
testLogging.events = ["FAILED", "STANDARD_OUT", "STANDARD_ERROR"]
}
}
javaLauncher.set(toolchainLauncher)
}
}
project(':benchmarks-api') {
dependencies {
api libs.agrona
api libs.hdrHistogram
}
}
project(':benchmarks-aeron') {
dependencies {
api project(':benchmarks-api')
annotationProcessor libs.jmh.generator.annprocess
implementation libs.jmh.core
implementation libs.aeron.cluster
implementation libs.disruptor
runtimeOnly libs.aeron.samples
}
}
project(':benchmarks-grpc') {
apply plugin: 'com.google.protobuf'
dependencies {
api project(':benchmarks-api')
implementation libs.grpc.protobuf
implementation libs.grpc.stub
implementation libs.grpc.netty.shaded
compileOnly libs.tomcat.annotations.api
}
protobuf {
protoc { artifact = "com.google.protobuf:protoc:${libs.versions.protoc.get()}" }
plugins {
grpc { artifact = "io.grpc:protoc-gen-grpc-java:${libs.versions.grpc.get()}" }
}
generateProtoTasks {
all()*.plugins { grpc {} }
}
}
sourceSets {
main {
proto {
srcDir 'source/main/proto'
srcDir 'build/generated/source/proto/main/java'
srcDir 'build/generated/source/proto/main/grpc'
}
}
}
tasks.processResources.dependsOn('generateProto')
}
project(':benchmarks-kafka') {
dependencies {
api project(':benchmarks-api')
implementation libs.kafka.clients
runtimeOnly libs.kafka
runtimeOnly libs.slf4j.log4j12
testImplementation libs.kafka
testImplementation libs.kafka.server.common
testImplementation libs.kafka.metadata
testRuntimeOnly libs.slf4j.log4j12
}
}
project(':benchmarks-all') {
apply plugin: 'com.gradleup.shadow'
dependencies {
implementation project(':benchmarks-aeron')
implementation project(':benchmarks-grpc')
implementation project(':benchmarks-kafka')
}
shadowJar {
archiveFileName = 'benchmarks.jar'
manifest.attributes('Main-Class': 'org.openjdk.jmh.Main')
mergeServiceFiles()
}
jar.finalizedBy shadowJar
}
static def benchmarkJvmArgs() {
return "-Dagrona.disable.bounds.checks=true -XX:+UseParallelGC --add-opens java.base/sun.nio.ch=ALL-UNNAMED"
}
tasks.register('runJavaIpcBenchmarks', Exec) {
dependsOn ':benchmarks-all:shadowJar'
commandLine toolchainLauncher.get().executablePath,
'-jar', 'benchmarks-all/build/libs/benchmarks.jar',
'-jvmArgs', benchmarkJvmArgs(),
'-wi', '3', '-w', '1s', '-i', '5', '-r', '1s', '-tu', 'ns', '-f', '5'
}
tasks.register('runAeronJavaIpcBenchmarks', Exec) {
dependsOn ':benchmarks-all:shadowJar'
commandLine toolchainLauncher.get().executablePath,
'-jar', 'benchmarks-all/build/libs/benchmarks.jar',
'-jvmArgs', benchmarkJvmArgs(),
'Aeron',
'-wi', '3', '-w', '1s', '-i', '5', '-r', '1s', '-tu', 'ns', '-f', '5'
}
def isNonStable = { String version ->
def stableKeyword = ['RELEASE', 'FINAL', 'GA'].any { it -> version.toUpperCase().contains(it) }
def regex = /^[0-9,.v-]+(-r)?$/
return !stableKeyword && !(version ==~ regex)
}
tasks.named("dependencyUpdates").configure {
// Reject all non stable versions
rejectVersionIf {
isNonStable(it.candidate.version)
}
}
FileTree benchmarksFileTree = fileTree('.') {
include 'benchmarks-all/build/libs/benchmarks.jar'
include 'scripts/**'
include 'certificates/**'
}
FileTree cDriverTree = (project.hasProperty('aeron.cdriver.package')) ?
tarTree(resources.gzip(project.property('aeron.cdriver.package'))) :
files().asFileTree
FileTree cDriverDpdkTree = (project.hasProperty('aeron.cdriver.dpdk.package')) ?
tarTree(resources.gzip(project.property('aeron.cdriver.dpdk.package'))) :
files().asFileTree
FileTree cDriverEfviTree = (project.hasProperty('aeron.cdriver.efvi.package')) ?
tarTree(resources.gzip(project.property('aeron.cdriver.efvi.package'))) :
files().asFileTree
FileTree cDriverAtsTree = (project.hasProperty('aeron.cdriver.ats.package')) ?
tarTree(resources.gzip(project.property('aeron.cdriver.ats.package'))) :
files().asFileTree
tasks.register('deployTar', Tar) {
dependsOn ':benchmarks-all:shadowJar'
from(benchmarksFileTree)
from(cDriverTree) {
include "*/**"
eachFile { fcd ->
fcd.relativePath = new RelativePath(true, (String[])fcd.relativePath.segments.drop(1))
}
includeEmptyDirs = false
}
from(cDriverDpdkTree)
from(cDriverAtsTree)
from(cDriverEfviTree)
}
tasks.register('copyTestLogs', Copy) {
from '.'
include '**/build/test-output/**'
include '**/*.log'
include '**/*.tlog'
include '**/build/reports/tests/**'
include '**/build/test-results/*/TEST*.xml'
include 'LICENSE'
exclude 'build'
into 'build/test_logs'
includeEmptyDirs = false
}
tasks.register('tarTestLogs', Tar) {
dependsOn tasks.named('copyTestLogs')
archiveBaseName.set('test_logs')
from 'build/test_logs'
compression Compression.BZIP2
}
wrapper {
gradleVersion = libs.versions.gradle.get()
distributionType = 'ALL'
}