Repository navigation
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
624 lines (558 loc) · 25.7 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
624 lines (558 loc) · 25.7 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
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
import org.gradle.kotlin.dsl.support.serviceOf
import tel.schich.dockcross.execute.DockerRunner
import tel.schich.dockcross.execute.NonContainerRunner
import tel.schich.dockcross.execute.RemoteSshRunner
import tel.schich.dockcross.tasks.DockcrossRunTask
import java.net.URI
import java.nio.file.Files
import java.nio.file.Paths
plugins {
id("tel.schich.libdatachannel.convention.common")
alias(libs.plugins.dockcross)
}
tasks.wrapper {
distributionType = Wrapper.DistributionType.ALL
}
fun extractLibDataChannelVersion(): String {
val regex = """#define\s+RTC_VERSION\s+"([^"]+)"""".toRegex()
val headerPath = project.layout.projectDirectory
.file("jni/libdatachannel/include/rtc/version.h")
.asFile.toPath()
val headerContent = Files.readString(headerPath)
val match = regex.find(headerContent) ?: return "unknown"
return match.groupValues[1]
}
fun produceVersion(): String {
val libDataChannelVersion = extractLibDataChannelVersion()
val hasTags = project.providers.exec {
commandLine("git", "tag")
}.standardOutput.asText.get().trim().isNotEmpty()
val defaultVersion = "$libDataChannelVersion.0-SNAPSHOT"
if (!hasTags) {
return defaultVersion
}
val describeOutput = project.providers.exec {
commandLine("git", "describe", "--tags")
}.standardOutput.asText.get().trim().removePrefix("v")
val parts = describeOutput.split("-", limit = 2)
val tagVersion = parts[0]
return if (parts.size > 1) {
if (tagVersion.startsWith(libDataChannelVersion)) {
val versionParts = tagVersion.split('.').toMutableList()
versionParts[versionParts.size - 1] = versionParts[versionParts.size - 1].toInt().inc().toString()
versionParts.joinToString(".") + "-SNAPSHOT"
} else {
defaultVersion
}
} else {
if (tagVersion.startsWith(libDataChannelVersion)) {
tagVersion
} else {
throw GradleException("The version derived from the latest git tag is conflicting with libdatachannel!")
}
}
}
version = providers.gradleProperty("libdatachannel.development-version").getOrElse(produceVersion())
val isSnapshot = version.toString().endsWith("-SNAPSHOT")
description = "${project.name} is a binding to the libdatachannel that feels native to Java developers."
fun gitRevision(vararg command: String): String = providers.exec {
commandLine(*command)
isIgnoreExitValue = true
}.standardOutput.asText.map { it.trim() }.getOrElse("").ifEmpty { "unknown" }
// Recorded in the jar so consumers can rebuild exactly this chain, for example to get a native
// library with the test diagnostics that release builds leave out.
tasks.jar {
manifest.attributes(
"Implementation-Title" to project.name,
"Implementation-Version" to project.version.toString(),
"Source-Revision" to gitRevision("git", "rev-parse", "HEAD"),
"LibDataChannel-Revision" to gitRevision("git", "rev-parse", "HEAD:jni/libdatachannel"),
"LibJuice-Revision" to gitRevision("git", "-C", "jni/libdatachannel", "rev-parse", "HEAD:deps/libjuice"),
)
}
val currentVersion = tasks.register<DefaultTask>("currentVersion") {
doLast {
println(version)
}
}
val archDetectConfiguration = configurations.register(Constants.ARCH_DETECT_CONFIG) {
isCanBeConsumed = true
}
val androidConfiguration = configurations.register(Constants.ANDROID_CONFIG) {
isCanBeConsumed = true
}
val jniPath = project.layout.projectDirectory.dir("jni")
tasks.compileJava.configure {
val annotationProcessorArgs = listOf(
"generate.jni.headers" to "true",
"generate.cache.mode.default" to "EAGER_PERSISTENT",
).map { "-A${it.first}=${it.second}" }
options.compilerArgs.addAll(annotationProcessorArgs)
options.headerOutputDirectory = jniPath.dir("generated")
}
val nativeGroup = "native"
val ci = System.getenv("CI") != null
val buildReleaseBinaries = project.findProperty("libdatachannel.build-release-binaries")
?.toString()
?.ifEmpty { null }
?.toBooleanStrictOrNull()
?: !project.version.toString().endsWith("-SNAPSHOT")
fun DockcrossRunTask.configureSshRemoteBuild(target: BuildTarget) {
if (!ci) {
return
}
fun findTarget(scope: String?): URI? {
return project.findProperty("libdatachannel${scope?.let { ".$it" }.orEmpty()}.ssh-target")
?.toString()
?.let(::URI)
}
val sshTarget = findTarget(scope = target.classifier)
?: findTarget(scope = target.family)
?: findTarget(scope = null)
?: return
val sshRunner = RemoteSshRunner(sshTarget) {
add("--exclude", "**/.git")
// this intentionally only includes the root-.gitignore, so that the generated jni files are included
add("--filter=.- .gitignore")
}
runner(sshRunner)
image = ""
}
fun DockcrossRunTask.baseConfigure(outputTo: Directory, target: BuildTarget) {
group = nativeGroup
dockcrossTag = "20250109-7bf589c"
inputs.file(project.layout.projectDirectory.file("jni/build.sh"))
when {
target.image == null -> {
image = "dummy"
}
'/' in target.image || ':' in target.image -> {
val parts = target.image.split(':', limit = 2)
dockcrossRepository = parts[0]
dockcrossTag = if (parts.size == 2) {
parts[1]
} else {
"latest"
}
image = "dummy"
}
else -> {
image = target.image
}
}
inputs.dir(jniPath)
dependsOn(tasks.compileJava)
output = outputTo.dir("native")
extraEnv.putAll(target.env)
extraEnv.put("JOBS", project.gradle.startParameter.maxWorkerCount.toString())
extraEnv.put("RELATIVE_PROJECT_PATH", output.get().asFile.toPath().relativize(jniPath.asFile.toPath()).toString())
extraEnv.put("PROJECT_VERSION", project.version.toString())
extraEnv.put("PROJECT_BUILD_TYPE", if (buildReleaseBinaries) "Release" else "Debug")
extraEnv.put("TARGET_FAMILY", target.family)
extraEnv.put("TARGET_CLASSIFIER", target.classifier)
target.image?.let {
extraEnv.put("TARGET_IMAGE", it)
}
script = listOf(listOf("bash", "../../../../jni/build.sh"))
configureSshRemoteBuild(target)
}
fun Jar.baseConfigure(compileTask: TaskProvider<out Task>, buildOutputDir: Directory) {
group = nativeGroup
dependsOn(compileTask)
from(buildOutputDir) {
include("native/libdatachannel-java.so")
include("native/libdatachannel-java.dll")
include("native/libdatachannel-java.dylib")
}
}
val dockcrossOutputDir: Directory = project.layout.buildDirectory.get().dir("dockcross")
val nativeForHostOutputDir: Directory = dockcrossOutputDir.dir("host")
val compileNativeForHost = tasks.register<DockcrossRunTask>("compileNativeForHost") {
baseConfigure(nativeForHostOutputDir, BuildTarget(image = null, family = "host", classifier = "host"))
unsafeWritableMountSource = true
runner(NonContainerRunner)
}
val packageNativeForHost = tasks.register<Jar>("packageNativeForHost") {
baseConfigure(compileNativeForHost, nativeForHostOutputDir)
archiveClassifier = "host"
}
data class BuildTarget(
val image: String?,
val family: String,
val classifier: String,
val nativeLinuxContainer: Boolean = false,
val env: Map<String, String> = emptyMap(),
val args: List<String> = emptyList(),
val outputTo: NamedDomainObjectProvider<Configuration> = archDetectConfiguration,
)
fun androidTarget(abi: String) = BuildTarget(
image = "ghcr.io/pschichtel/cross-build/android:20250620-f1c8ddd",
family = "android",
classifier = "${Constants.ANDROID_CLASSIFIER_PREFIX}$abi",
env = mapOf("ANDROID_ABI" to abi),
outputTo = androidConfiguration,
)
fun macosTarget(classifier: String, arch: String) = BuildTarget(
image = "ghcr.io/pschichtel/cross-build/osx:20250620-f1c8ddd",
family = "macos",
classifier = "${Constants.MACOS_CLASSIFIER_PREFIX}$classifier",
env = mapOf("OSXCROSS_HOST" to "$arch-apple-darwin23.6"),
)
val allTargets = listOf(
BuildTarget(
image = null,
family = "linux",
classifier = "${Constants.LINUX_CLASSIFIER_PREFIX}glibc-x86_64",
),
// BuildTarget(
// image = "linux-x86",
// family = "linux",
// classifier = "${Constants.LINUX_CLASSIFIER_PREFIX}x86_32",
// ),
BuildTarget(
image = null,
family = "linux",
classifier = "${Constants.LINUX_CLASSIFIER_PREFIX}glibc-aarch64",
),
BuildTarget(
image = "alpine:3.22",
family = "linux",
classifier = "linux-musl-x86_64",
nativeLinuxContainer = true,
),
BuildTarget(
image = "alpine:3.22",
family = "linux",
classifier = "linux-musl-aarch64",
nativeLinuxContainer = true,
),
BuildTarget(
image = "windows-static-x64",
family = "windows",
classifier = "${Constants.WINDOWS_CLASSIFIER_PREFIX}x86_64",
),
// dockcross has no static arm64 image, the llvm-mingw runtime is linked in by -static instead.
// Conan's mingw fallback for armv8 is the generic mingw-common, which carries no arm64
// assembly, so OpenSSL's own target for this architecture is picked explicitly.
BuildTarget(
image = "windows-arm64",
family = "windows",
classifier = "${Constants.WINDOWS_CLASSIFIER_PREFIX}aarch64",
env = mapOf("CONAN_OPENSSL_CONFIGURATION" to "mingwarm64"),
),
// BuildTarget(
// image = "windows-static-x86",
// family = "windows",
// classifier = "${Constants.WINDOWS_CLASSIFIER_PREFIX}x86_32",
// ),
androidTarget(abi = "armeabi-v7a"),
androidTarget(abi = "arm64-v8a"),
androidTarget(abi = "x86"),
androidTarget(abi = "x86_64"),
macosTarget(classifier = "arm64", arch = "aarch64"),
macosTarget(classifier = "x86_64", arch = "x86_64"),
)
// Optional comma separated list of target classifiers, defaults to all targets.
val targets = providers.gradleProperty("libdatachannel.targets")
.map { spec ->
val requested = spec.split(",").map { it.trim() }.filter { it.isNotEmpty() }.toSet()
val known = allTargets.map { it.classifier }.toSet()
val unknown = requested - known
if (unknown.isNotEmpty()) {
throw GradleException("Unknown targets: ${unknown.sorted().joinToString()}, known targets: ${known.sorted().joinToString()}")
}
allTargets.filter { it.classifier in requested }
}
.getOrElse(allTargets)
val packageNativeAll = tasks.register<DefaultTask>("packageNativeAll") {
group = nativeGroup
}
var previousCompileNative: TaskProvider<DockcrossRunTask>? = null
for (target in targets) {
val outputDir: Directory = dockcrossOutputDir.dir(target.classifier)
val taskSuffix = target.classifier.split("[_-]".toRegex())
.joinToString(separator = "") { it.lowercase().replaceFirstChar(Char::uppercaseChar) }
val prebuiltPath = project.findProperty("libdatachannel.${target.classifier}.prebuilt-path")
?.toString()
?.ifBlank { null }
?.let { Paths.get(it).toFile() }
val packageTaskName = "packageNativeFor$taskSuffix"
val packageNative = if (prebuiltPath == null) {
val compileNative: TaskProvider<out Task>
if (target.nativeLinuxContainer) {
compileNative = tasks.register<Exec>("compileNativeFor$taskSuffix") {
group = nativeGroup
dependsOn(tasks.compileJava)
inputs.dir(jniPath)
inputs.property("version", project.version.toString())
inputs.property("release", buildReleaseBinaries)
inputs.property("image", target.image!!)
outputs.file(outputDir.file("native/libdatachannel-java.so"))
val architecture = if (target.classifier.endsWith("aarch64")) {
"arm64"
} else {
"amd64"
}
commandLine("docker", "run", "--rm", "--platform", "linux/$architecture",
"-v", "${project.projectDir}:/work:z", "-w", "/work",
"-e", "TARGET_CLASSIFIER=${target.classifier}",
"-e", "PROJECT_VERSION=${project.version}",
"-e", "PROJECT_BUILD_TYPE=${if (buildReleaseBinaries) "Release" else "Debug"}",
"-e", "JOBS=${project.gradle.startParameter.maxWorkerCount}",
target.image!!, "sh", "jni/build-alpine.sh")
}
} else if (target.classifier.startsWith("linux-glibc-")) {
compileNative = tasks.register<Exec>("compileNativeFor$taskSuffix") {
group = nativeGroup
dependsOn(tasks.compileJava)
inputs.dir(jniPath)
inputs.property("version", project.version.toString())
inputs.property("release", buildReleaseBinaries)
outputs.file(outputDir.file("native/libdatachannel-java.so"))
environment("TARGET_CLASSIFIER", target.classifier)
environment("PROJECT_VERSION", project.version.toString())
environment("PROJECT_BUILD_TYPE", if (buildReleaseBinaries) "Release" else "Debug")
environment("JOBS", project.gradle.startParameter.maxWorkerCount.toString())
commandLine("sh", "jni/build-linux.sh")
}
} else if (target.family == "windows" && System.getProperty("os.name").startsWith("Windows")) {
compileNative = tasks.register<Exec>("compileNativeFor$taskSuffix") {
group = nativeGroup
dependsOn(tasks.compileJava)
inputs.dir(jniPath)
inputs.property("version", project.version.toString())
inputs.property("release", buildReleaseBinaries)
outputs.file(outputDir.file("native/libdatachannel-java.dll"))
environment("TARGET_CLASSIFIER", target.classifier)
environment("PROJECT_VERSION", project.version.toString())
environment("PROJECT_BUILD_TYPE", if (buildReleaseBinaries) "Release" else "Debug")
environment("JOBS", project.gradle.startParameter.maxWorkerCount.toString())
commandLine(providers.environmentVariable("MSYS2_BASH").getOrElse("bash"), "jni/build-windows.sh")
}
} else {
val dockcrossCompile = tasks.register("compileNativeFor$taskSuffix", DockcrossRunTask::class) {
baseConfigure(outputDir, target)
unsafeWritableMountSource = true
containerName = "dockcross-${project.name}-${target.classifier}"
}
if (ci) {
val previous = previousCompileNative
dockcrossCompile {
if (target.image == null) {
runner(NonContainerRunner)
} else {
runner(DockerRunner())
}
if (previous != null) {
mustRunAfter(previous)
}
if (target.image != null) {
val execOps = project.serviceOf<ExecOperations>()
doLast {
execOps.exec {
commandLine("docker", "image", "prune", "-af")
}
}
}
}
previousCompileNative = dockcrossCompile
}
compileNative = dockcrossCompile
}
tasks.register(packageTaskName, Jar::class) {
baseConfigure(compileNative, outputDir)
archiveClassifier = target.classifier
}
} else {
tasks.register(packageTaskName, Jar::class) {
group = nativeGroup
from(prebuiltPath.parentFile) {
include(prebuiltPath.name)
includeEmptyDirs = false
eachFile {
val fileName = when (target.family) {
"macos" -> "libdatachannel-java.dylib"
"windows" -> "libdatachannel-java.dll"
else -> "libdatachannel-java.so"
}
relativePath = RelativePath.parse(true, "native/$fileName")
}
}
archiveClassifier = target.classifier
doFirst {
if (!prebuiltPath.exists()) {
throw GradleException("Prebuilt binary for $target does not exist: $prebuiltPath")
}
}
}
}
publishing.publications.withType<MavenPublication>().configureEach {
artifact(packageNative)
}
packageNativeAll.configure {
dependsOn(packageNative)
}
artifacts.add(target.outputTo.name, packageNative)
}
dependencies {
annotationProcessor(libs.jniAccessGenerator)
compileOnly(libs.jniAccessGenerator)
if (providers.gradleProperty("libdatachannel.test-native-path").isPresent) {
// Package the selected binary on the classpath so child JVM lifecycle probes
// load the same checkout's library without relying on inherited properties.
val focusedNative = tasks.register<Jar>("packageNativeForFocusedTests") {
dependsOn("compileNativeProbe")
archiveFileName = "focused-test-native.jar"
destinationDirectory = layout.buildDirectory.dir("focused-test-native")
from(providers.gradleProperty("libdatachannel.test-native-path")) {
into("native")
rename { "libdatachannel-java.so" }
}
}
testImplementation(files(focusedNative))
} else {
testImplementation(files(packageNativeForHost))
}
testRuntimeOnly(libs.junitPlatformLauncher)
testImplementation(libs.junitJupiter)
}
tasks.test {
useJUnitPlatform()
}
publishing.publications.withType<MavenPublication>().configureEach {
pom {
description = "${project.description}"
}
}
val openCollabDeploy = tasks.register<DefaultTask>("openCollabDeploy") {
group = "publishing"
val repo = if (isSnapshot) {
Constants.SNAPSHOTS_REPO
} else {
Constants.RELEASES_REPO
}
val hasAndroidTargets = targets.any { it.family == "android" }
for (project in allprojects) {
// the android module bundles the android natives, publishing it without them makes no sense
if (!hasAndroidTargets && project.name.endsWith("-android")) {
continue
}
val publishTasks = project.tasks
.withType<PublishToMavenRepository>()
.matching { it.repository.name == repo }
dependsOn(publishTasks)
}
doFirst {
logger.lifecycle("Deploying $version to $repo!")
}
}
val githubActions = tasks.register<DefaultTask>("githubActions") {
group = "publishing"
val deployRefPattern = """^refs/(?:tags/v\d+\.\d+\.\d+\.\d+|heads/main)$""".toRegex()
val ref = System.getenv("GITHUB_REF")?.ifBlank { null }?.trim()
dependsOn(tasks.check)
if (System.getenv("GITHUB_REPOSITORY") == "opencollab-incubator/libdatachannel-java" && ref != null && deployRefPattern.matches(ref)) {
logger.lifecycle("Job in $ref will deploy!")
dependsOn(openCollabDeploy)
} else {
logger.lifecycle("Job will only build!")
dependsOn(tasks.assemble)
}
}
// Focused local JNI transport tests using the existing library/package format.
// Uses system OpenSSL; the established dockcross release path remains available.
val configureNativeProbe by tasks.registering(Exec::class) {
dependsOn(tasks.compileJava)
commandLine("cmake", "-S", "jni", "-B", "build/native-probe", "-DCMAKE_POLICY_VERSION_MINIMUM=3.5",
"-DLIBDATACHANNEL_SOURCE_DIR=${project.file("jni/libdatachannel").absolutePath}", "-DUSE_SYSTEM_JUICE=OFF",
"-DCMAKE_BUILD_TYPE=Debug", "-DPROJECT_VERSION=${project.version}", "-DENABLE_LOCALHOST_ADDRESS=ON",
"-DTRANSPORT_TEARDOWN_TESTS=ON", "-DPENDING_MUX_TESTS=ON", "-DICE_UDP_MUX_TESTS=ON",
"-DRTC_ENABLE_TEST_DIAGNOSTICS=ON")
}
val compileNativeProbe by tasks.registering(Exec::class) {
dependsOn(configureNativeProbe)
commandLine("cmake", "--build", "build/native-probe", "--target", "datachannel-java", "transport-teardown-test", "ice-udp-mux-pending-test", "candidate-pair-buffer-test", "mux-pending-test", "mux-pending-lifetime-test", "mux-authentication-test", "mux-direct-test", "mux-admission-test", "mux-proxy-protocol-test", "ice-attribute-limits-test", "-j2")
}
val probeSourceSet = sourceSets.create("nativeProbe") {
java.srcDir("native-test")
compileClasspath += sourceSets.main.get().output + configurations.compileClasspath.get()
runtimeClasspath += sourceSets.main.get().output + configurations.runtimeClasspath.get()
}
dependencies {
add(probeSourceSet.implementationConfigurationName, libs.logbackClassic)
}
tasks.named<JavaCompile>(probeSourceSet.compileJavaTaskName) {
javaCompiler = javaToolchains.compilerFor { languageVersion = JavaLanguageVersion.of(17) }
options.release = 17
}
val probeIdentity by tasks.registering(Exec::class) {
val dir = layout.buildDirectory.dir("probe-identity")
outputs.dir(dir)
doFirst { dir.get().asFile.mkdirs() }
commandLine("openssl", "req", "-x509", "-newkey", "ec", "-pkeyopt", "ec_paramgen_curve:prime256v1",
"-nodes", "-days", "1", "-subj", "/CN=native-probe", "-keyout", "build/probe-identity/key.pem", "-out", "build/probe-identity/cert.pem")
}
val probeEncryptedIdentity by tasks.registering(Exec::class) {
dependsOn(probeIdentity)
inputs.file("build/probe-identity/key.pem")
outputs.file("build/probe-identity/key-encrypted.pem")
commandLine("openssl", "pkcs8", "-topk8", "-in", "build/probe-identity/key.pem",
"-out", "build/probe-identity/key-encrypted.pem", "-v2", "aes-256-cbc", "-passout", "pass:test-only-password")
}
val runTransportNativeTests by tasks.registering(Exec::class) {
dependsOn(compileNativeProbe)
commandLine("ctest", "--test-dir", "build/native-probe/libdatachannel", "--output-on-failure", "-R", "transport.teardown|mux.pending|mux.authentication|mux.direct|mux.admission|mux.proxy.protocol|ice.attribute.limits")
}
tasks.register<JavaExec>("nativeTransportProbe") {
dependsOn(runTransportNativeTests, probeIdentity, probeEncryptedIdentity, tasks.named(probeSourceSet.classesTaskName), "nativeCallbackCleanupProbe", "nativeCallbackDispatchProbe", "nativeLoggingProbe", "nativeStunMonitorProbe", "nativeCandidatePairBufferProbe")
javaLauncher = javaToolchains.launcherFor { languageVersion = JavaLanguageVersion.of(17) }
classpath = probeSourceSet.runtimeClasspath
mainClass = "tel.schich.libdatachannel.NativeTransportProbe"
systemProperty("libdatachannel.native.datachannel-java.path", layout.buildDirectory.file("native-probe/libdatachannel-java.so").get().asFile.absolutePath)
args("build/probe-identity/cert.pem", "build/probe-identity/key.pem", "build/probe-identity/key-encrypted.pem")
}
tasks.register<Exec>("nativeCandidatePairBufferProbe") {
dependsOn(compileNativeProbe)
commandLine(layout.buildDirectory.file("native-probe/candidate-pair-buffer-test").get().asFile.absolutePath)
}
tasks.register<JavaExec>("nativeCallbackCleanupProbe") {
dependsOn(compileNativeProbe, tasks.named(probeSourceSet.classesTaskName))
javaLauncher = javaToolchains.launcherFor { languageVersion = JavaLanguageVersion.of(17) }
classpath = probeSourceSet.runtimeClasspath
mainClass = "tel.schich.libdatachannel.CallbackCleanupProbe"
systemProperty("libdatachannel.native.datachannel-java.path", layout.buildDirectory.file("native-probe/libdatachannel-java.so").get().asFile.absolutePath)
}
tasks.register<JavaExec>("nativeCallbackDispatchProbe") {
dependsOn(compileNativeProbe, tasks.named(probeSourceSet.classesTaskName))
javaLauncher = javaToolchains.launcherFor { languageVersion = JavaLanguageVersion.of(17) }
classpath = probeSourceSet.runtimeClasspath
mainClass = "tel.schich.libdatachannel.CallbackDispatchProbe"
// Turns a released global reference into a fatal error instead of whatever the heap holds
jvmArgs("-Xcheck:jni")
systemProperty("libdatachannel.native.datachannel-java.path", layout.buildDirectory.file("native-probe/libdatachannel-java.so").get().asFile.absolutePath)
}
tasks.register<JavaExec>("nativeLoggingProbe") {
dependsOn(compileNativeProbe, tasks.named(probeSourceSet.classesTaskName))
javaLauncher = javaToolchains.launcherFor { languageVersion = JavaLanguageVersion.of(17) }
classpath = probeSourceSet.runtimeClasspath
mainClass = "tel.schich.libdatachannel.NativeLoggingProbe"
systemProperty("libdatachannel.native.datachannel-java.path", layout.buildDirectory.file("native-probe/libdatachannel-java.so").get().asFile.absolutePath)
}
tasks.register<JavaExec>("nativeStunMonitorProbe") {
dependsOn(compileNativeProbe, tasks.named(probeSourceSet.classesTaskName))
javaLauncher = javaToolchains.launcherFor { languageVersion = JavaLanguageVersion.of(17) }
classpath = probeSourceSet.runtimeClasspath
mainClass = "tel.schich.libdatachannel.NativeStunMonitorProbe"
systemProperty("libdatachannel.native.datachannel-java.path", layout.buildDirectory.file("native-probe/libdatachannel-java.so").get().asFile.absolutePath)
}
// A portable classpath for running the shipped bundle inside target JVMs.
tasks.register<Sync>("prepareNativeSmoke") {
dependsOn(tasks.named(probeSourceSet.classesTaskName))
from(tasks.jar)
from(project(":libdatachannel-java-arch-detect").tasks.named("jar"))
from(configurations[probeSourceSet.runtimeClasspathConfigurationName])
from(probeSourceSet.output) {
into("classes")
}
into(layout.buildDirectory.dir("native-smoke"))
}