Repository navigation
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
1701 lines (1554 loc) · 67.1 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
1701 lines (1554 loc) · 67.1 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
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* MIT License
*
* Copyright (c) 2021-2026. Aleksandr Serdiukov, Anton Zamyatin, Aleksandr Sinitsyn, Vitalii Dravgelis and Computer Technologies Laboratory ITMO University team.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.gradle.api.GradleException
import org.gradle.api.file.RelativePath
import org.gradle.api.tasks.testing.logging.TestLogEvent.*
import org.gradle.language.jvm.tasks.ProcessResources
import java.io.ByteArrayOutputStream
import java.net.URI
import java.security.MessageDigest
import java.nio.file.Files
import java.nio.file.StandardCopyOption
import java.nio.file.StandardCopyOption.REPLACE_EXISTING
import java.util.zip.ZipFile
plugins {
java
application
id("com.gradleup.shadow") version "8.3.9"
id("io.freefair.lombok") version "8.10.2"
}
group = "ru.itmo.ctlab.hict"
repositories {
mavenCentral()
maven {
url = uri("https://maven.scijava.org/content/repositories/public/")
}
}
val vertxVersion = "4.5.36"
val junitJupiterVersion = "5.9.1"
val junitPlatformVersion = "1.9.1"
val slf4jVersion = "2.0.20"
val logbackVersion = "1.5.38"
dependencyLocking {
lockAllConfigurations()
}
val mainVerticleName = "ru.itmo.ctlab.hict.hict_server.MainVerticle"
val launcherClassName = "io.vertx.core.Launcher"
val watchForChange = "src/**/*"
val doOnChange = "${projectDir}/gradlew classes"
val versionFile = file("${project.projectDir}/version.txt")
val changelogFile = file("${project.projectDir}/CHANGELOG.md")
val releaseWebUIPin = file("webui-revision.txt").readText().trim().also {
require(it.matches(Regex("[0-9a-f]{40}"))) { "Invalid release WebUI revision" }
}
val backendRevision = providers.environmentVariable("HICT_BACKEND_REVISION")
.orElse(providers.exec {
commandLine("git", "rev-parse", "HEAD")
}.standardOutput.asText)
.map { revision ->
revision.trim().also { require(it.matches(Regex("[0-9a-f]{40}"))) { "Invalid JVM revision" } }
}
val releaseBuildVersion = providers.environmentVariable("HICT_BUILD_VERSION")
.orElse(providers.gradleProperty("portableReleaseVersion")).orNull
fun buildVersion(base: String): String = releaseBuildVersion?.also {
require(it == base) { "HICT_BUILD_VERSION differs from the version assigned by CI" }
} ?: "${base.substringBefore("-")}-${backendRevision.get().take(7)}-webui_${releaseWebUIPin.take(7)}"
val requestedWebUI = providers.gradleProperty("webuiRef").orNull ?: System.getenv("HICT_WEBUI_REF")
val releaseWebUIRequired = (providers.gradleProperty("requireBundledWebUI").orNull ?: System.getenv("HICT_REQUIRE_BUNDLED_WEBUI"))
?.lowercase() in setOf("true", "1", "yes")
val webUIRefOverride = if (releaseWebUIRequired) {
require(requestedWebUI == null || requestedWebUI == "same-as-jvm" || requestedWebUI == releaseWebUIPin) {
"The requested WebUI differs from webui-revision.txt"
}
releaseWebUIPin
} else requestedWebUI
val explicitWebUIRef = !webUIRefOverride.isNullOrBlank() && !webUIRefOverride.trim().equals("same-as-jvm", ignoreCase = true)
val webUICloneDirectory = layout.buildDirectory.dir("webui").get()
val localWebUIRepositoryDirectory = layout.projectDirectory.dir("../HiCT_WebUI")
val remoteWebUIRepositoryDirectory = webUICloneDirectory.dir("HiCT_WebUI")
val useLocalWebUI = localWebUIRepositoryDirectory.asFile.exists() && !explicitWebUIRef
val webUIRepositoryDirectory =
if (useLocalWebUI) localWebUIRepositoryDirectory else remoteWebUIRepositoryDirectory
val webUIRepositoryAddress = "https://github.com/ctlab/HiCT_WebUI.git"
val webUITargetDirectory = layout.projectDirectory.dir("src/main/resources/webui")
val bundledToolchainSourceDirectory = layout.projectDirectory.dir("toolchains-dist")
val webUIFallbackRef = "master"
val webUISameAsJvmRefToken = "same-as-jvm"
val npmExecutable = if (System.getProperty("os.name").lowercase().contains("windows")) "npm.cmd" else "npm"
val requireBundledWebUI =
(providers.gradleProperty("requireBundledWebUI").orNull ?: System.getenv("HICT_REQUIRE_BUNDLED_WEBUI"))
?.let { it.equals("true", ignoreCase = true) || it == "1" || it.equals("yes", ignoreCase = true) }
?: false
val requireWebUIConverterDtoChecks =
(providers.gradleProperty("requireWebUIConverterDtoChecks").orNull ?: System.getenv("HICT_REQUIRE_WEBUI_CONVERTER_CHECKS"))
?.let { it.equals("true", ignoreCase = true) || it == "1" || it.equals("yes", ignoreCase = true) }
?: false
val nativeProcessingLibraryBaseName = "hict_native"
val nativeProcessingSourceFile = layout.projectDirectory.file("src/main/native/hict_native.cpp")
val nativeProcessingResourceRoot = layout.buildDirectory.dir("native-processing/resources")
data class NativeProcessingVariant(
val id: String,
val taskSuffix: String,
val libraryBaseName: String,
val gnuCompileFlags: List<String>,
val msvcCompileFlags: List<String>,
val description: String
)
val nativeProcessingVariants = listOf(
NativeProcessingVariant(
id = "sse2",
taskSuffix = "Sse2",
libraryBaseName = "${nativeProcessingLibraryBaseName}_sse2",
gnuCompileFlags = listOf("-msse2"),
msvcCompileFlags = emptyList(),
description = "x86-64 SSE2 baseline build"
),
NativeProcessingVariant(
id = "avx2",
taskSuffix = "Avx2",
libraryBaseName = nativeProcessingLibraryBaseName,
gnuCompileFlags = listOf("-mavx2", "-mfma", "-msse4.2", "-mbmi", "-mbmi2"),
msvcCompileFlags = listOf("/arch:AVX2"),
description = "x86-64 AVX2/FMA/BMI2 build"
),
NativeProcessingVariant(
id = "avx512",
taskSuffix = "Avx512",
libraryBaseName = "${nativeProcessingLibraryBaseName}_avx512",
gnuCompileFlags = listOf(
"-mavx2",
"-mfma",
"-msse4.2",
"-mbmi",
"-mbmi2",
"-mavx512f",
"-mavx512dq",
"-mavx512bw",
"-mavx512vl",
"-DHICT_NATIVE_AVX512=1"
),
msvcCompileFlags = listOf("/arch:AVX512", "/DHICT_NATIVE_AVX512=1"),
description = "AVX-512F/DQ/BW/VL build"
)
)
val nativeProcessingOpenMpEnabled =
(providers.gradleProperty("nativeOpenmp").orNull ?: System.getenv("HICT_NATIVE_OPENMP"))
?.let { it.equals("true", ignoreCase = true) || it == "1" || it.equals("yes", ignoreCase = true) }
?: false
val requireNativeProcessingVariants =
(providers.gradleProperty("requireNativeProcessingVariants").orNull ?: System.getenv("HICT_REQUIRE_NATIVE_PROCESSING_VARIANTS"))
?.let { it.equals("true", ignoreCase = true) || it == "1" || it.equals("yes", ignoreCase = true) }
?: false
fun nativeProcessingPlatformDirectory(): String? {
val os = System.getProperty("os.name").lowercase()
val arch = System.getProperty("os.arch").lowercase()
val is64Bit = arch.contains("64") || arch == "amd64" || arch == "x86_64"
if (!is64Bit) {
return null
}
return when {
os.contains("linux") -> "linux_64"
os.contains("win") -> "windows_64"
os.contains("mac") || os.contains("darwin") -> "macos_64"
else -> null
}
}
fun nativeProcessingJniIncludeDirectory(): String? {
val os = System.getProperty("os.name").lowercase()
return when {
os.contains("linux") -> "linux"
os.contains("mac") || os.contains("darwin") -> "darwin"
os.contains("win") -> "win32"
else -> null
}
}
fun executableOnPath(executableName: String): Boolean {
val path = System.getenv("PATH") ?: return false
return path.split(File.pathSeparator)
.asSequence()
.map { File(it, executableName) }
.any { it.isFile && it.canExecute() }
}
fun nativeProcessingCompilerExecutable(): String? {
val override = providers.gradleProperty("nativeCxx").orNull
?: System.getenv("HICT_NATIVE_CXX")
if (!override.isNullOrBlank()) {
val overrideFile = File(override)
if (overrideFile.isAbsolute) {
return override.takeIf { overrideFile.isFile && overrideFile.canExecute() }
}
return override.takeIf { executableOnPath(it) }
}
val os = System.getProperty("os.name").lowercase()
val candidates = if (os.contains("win")) {
listOf("cl.exe", "cl", "clang-cl.exe", "clang-cl", "g++", "clang++")
} else {
listOf("g++", "clang++")
}
return candidates.firstOrNull(::executableOnPath)
}
fun nativeProcessingCompilerFlavor(compilerExecutable: String?): String? {
if (compilerExecutable.isNullOrBlank()) {
return null
}
val executableName = File(compilerExecutable).name.lowercase().removeSuffix(".exe")
return when {
executableName == "cl" || executableName == "clang-cl" -> "msvc"
executableName == "g++" || executableName == "clang++" || executableName.endsWith("-g++") -> "gnu"
else -> null
}
}
fun nativeProcessingCompilerSupportsCurrentOs(compilerExecutable: String? = nativeProcessingCompilerExecutable()): Boolean {
val os = System.getProperty("os.name").lowercase()
val compilerFlavor = nativeProcessingCompilerFlavor(compilerExecutable)
return when {
os.contains("win") -> compilerFlavor == "msvc" || compilerFlavor == "gnu"
else -> compilerFlavor == "gnu"
}
}
fun nativeProcessingOutputFile(variant: NativeProcessingVariant): File {
val platformDirectory = nativeProcessingPlatformDirectory() ?: "unsupported"
val mappedLibraryName = System.mapLibraryName(variant.libraryBaseName)
val variantDirectory = nativeProcessingResourceVariantDirectory(variant.id)
return nativeProcessingResourceRoot
.map { it.file("natives/$platformDirectory/$variantDirectory/native/$mappedLibraryName") }
.get()
.asFile
}
fun nativeProcessingResourceVariantDirectory(variantId: String): String = when (variantId.lowercase()) {
"sse2", "generic", "x86_64-v3" -> "generic"
else -> variantId.lowercase()
}
fun handleMissingWebUI(message: String, cause: Throwable? = null) {
if (requireBundledWebUI) {
throw GradleException(message, cause)
}
if (cause == null) {
logger.warn(message)
} else {
logger.warn(message, cause)
}
}
fun emitCiWarning(message: String) {
if (System.getenv("GITHUB_ACTIONS").equals("true", ignoreCase = true)) {
println("::warning::${message.replace('\n', ' ')}")
}
logger.warn(message)
}
fun envOrProjectProperty(name: String): String? =
(findProperty(name) as String?)?.takeIf { it.isNotBlank() }
?: System.getenv(name)?.takeIf { it.isNotBlank() }
fun selectedBundledToolchainPlatforms(): List<String> {
val override = envOrProjectProperty("HICT_BUNDLED_TOOLCHAIN_PLATFORMS")
?: envOrProjectProperty("hictBundledToolchainPlatforms")
if (!override.isNullOrBlank()) {
if (override.equals("all", ignoreCase = true)) {
val root = bundledToolchainSourceDirectory.asFile
return if (root.isDirectory) {
root.listFiles()
?.filter { it.isDirectory }
?.map { it.name }
?.sorted()
?: emptyList()
} else {
emptyList()
}
}
return override.split(',', ';', ' ', '\n')
.map { it.trim() }
.filter { it.isNotBlank() }
.distinct()
}
envOrProjectProperty("HICT_DARWIN_PLATFORM_DIR")?.let { return listOf(it) }
val osName = System.getProperty("os.name").lowercase()
val osArch = System.getProperty("os.arch").lowercase()
return when {
osName.contains("win") -> listOf("windows_x86_64")
osName.contains("mac") || osName.contains("darwin") ->
if (osArch.contains("aarch64") || osArch.contains("arm64")) listOf("darwin_arm64") else listOf("darwin_x86_64")
osName.contains("linux") -> listOf("linux_x86_64")
else -> emptyList()
}
}
val bundledToolchainPlatforms = selectedBundledToolchainPlatforms()
val jhdf5SourceMode = (envOrProjectProperty("HICT_JHDF5_SOURCE_MODE")
?: envOrProjectProperty("hictJhdf5SourceMode")
?: "release").lowercase()
val useMavenJhdf5 = jhdf5SourceMode in setOf("maven", "maven-central", "published") ||
envOrProjectProperty("HICT_USE_MAVEN_JHDF5")
?.let { it == "1" || it.equals("true", ignoreCase = true) || it.equals("yes", ignoreCase = true) }
?: false
val bundledJhdf5JarName = envOrProjectProperty("HICT_JHDF5_JAR_NAME")
?: "sis-jhdf5-19.04.1-slim.jar"
val bundledJhdf5FallbackJarName = envOrProjectProperty("HICT_JHDF5_FALLBACK_JAR_NAME")
?: "sis-jhdf5-19.04.1.jar"
val bundledJhdf5DefaultLocalJarPath = "src/main/resources/libs/$bundledJhdf5JarName"
val bundledJhdf5LocalJarPath = envOrProjectProperty("HICT_JHDF5_LOCAL_JAR")
?: envOrProjectProperty("hictJhdf5LocalJar")
?: bundledJhdf5DefaultLocalJarPath
val bundledJhdf5FallbackLocalJarPath = "src/main/resources/libs/$bundledJhdf5FallbackJarName"
val bundledJhdf5DownloadUrl = envOrProjectProperty("HICT_JHDF5_DOWNLOAD_URL")
?: envOrProjectProperty("hictJhdf5DownloadUrl")
?: "https://github.com/AxisAlexNT/jhdf5-with-plugins-configuration-snapshot/releases/download/release-artifacts/$bundledJhdf5JarName"
val bundledJhdf5FallbackDownloadUrl = envOrProjectProperty("HICT_JHDF5_FALLBACK_DOWNLOAD_URL")
?: "https://github.com/AxisAlexNT/jhdf5-with-plugins-configuration-snapshot/releases/download/release-artifacts/$bundledJhdf5FallbackJarName"
val bundledJhdf5NativesArchiveName = envOrProjectProperty("HICT_JHDF5_NATIVES_ARCHIVE_NAME")
?: "sis-jhdf5-19.04.1-natives.tar.gz"
val bundledJhdf5NativesArchivePath = envOrProjectProperty("HICT_JHDF5_NATIVES_ARCHIVE")
?: envOrProjectProperty("HICT_JHDF5_NATIVES_ARCHIVE_PATH")
?: "src/main/resources/libs/$bundledJhdf5NativesArchiveName"
val bundledJhdf5NativesArchiveDownloadUrl = envOrProjectProperty("HICT_JHDF5_NATIVES_ARCHIVE_URL")
?: "https://github.com/AxisAlexNT/jhdf5-with-plugins-configuration-snapshot/releases/download/release-artifacts/$bundledJhdf5NativesArchiveName"
val preferBundledJhdf5NativesArchive = bundledJhdf5JarName.contains("slim", ignoreCase = true) ||
(envOrProjectProperty("HICT_REQUIRE_JHDF5_NATIVES_ARCHIVE")
?.let { it == "1" || it.equals("true", ignoreCase = true) || it.equals("yes", ignoreCase = true) }
?: false)
val requireBundledJhdf5 = !useMavenJhdf5 && (envOrProjectProperty("HICT_REQUIRE_BUNDLED_JHDF5")
?.let { it == "1" || it.equals("true", ignoreCase = true) || it.equals("yes", ignoreCase = true) }
?: false)
fun downloadFile(url: String, target: File, label: String): File? {
if (target.isFile) {
return target
}
return try {
target.parentFile.mkdirs()
URI(url).toURL().openStream().use { stream ->
Files.copy(stream, target.toPath(), REPLACE_EXISTING)
}
logger.lifecycle("Downloaded $label from $url to ${target.absolutePath}")
target.takeIf { it.isFile }
} catch (err: Exception) {
target.delete()
logger.warn("Failed to download $label from $url: ${err.message}")
null
}
}
fun downloadedJhdf5JarFile(): File? {
if (useMavenJhdf5 || jhdf5SourceMode == "local") {
return null
}
val target = file(".gradle/jhdf5/$bundledJhdf5JarName")
downloadFile(bundledJhdf5DownloadUrl, target, "bundled JHDF5 jar")?.let { return it }
if (bundledJhdf5FallbackJarName != bundledJhdf5JarName) {
val fallbackTarget = file(".gradle/jhdf5/$bundledJhdf5FallbackJarName")
return downloadFile(bundledJhdf5FallbackDownloadUrl, fallbackTarget, "fallback bundled JHDF5 jar")
}
return null
}
fun bundledJhdf5LocalJarFile(): File? = if (useMavenJhdf5) {
null
} else {
sequenceOf(bundledJhdf5LocalJarPath, bundledJhdf5FallbackLocalJarPath)
.distinct()
.map { file(it) }
.firstOrNull { it.isFile }
?: downloadedJhdf5JarFile()
}
fun downloadedJhdf5NativesArchiveFile(): File? {
if (useMavenJhdf5 || jhdf5SourceMode == "local" || !preferBundledJhdf5NativesArchive) {
return null
}
val target = file(".gradle/jhdf5/$bundledJhdf5NativesArchiveName")
return downloadFile(bundledJhdf5NativesArchiveDownloadUrl, target, "bundled JHDF5 native archive")
}
fun bundledJhdf5NativesArchiveFile(): File? = if (useMavenJhdf5) {
null
} else {
file(bundledJhdf5NativesArchivePath)
.takeIf { it.isFile }
?: downloadedJhdf5NativesArchiveFile()
}
val runtimeJhdf5NativesArchiveFile = layout.buildDirectory.file("jhdf5-runtime/$bundledJhdf5NativesArchiveName")
fun selectedRuntimeJhdf5NativePlatforms(): List<String> {
val explicit = envOrProjectProperty("HICT_JHDF5_RUNTIME_PLATFORMS")
?: envOrProjectProperty("hictJhdf5RuntimePlatforms")
if (!explicit.isNullOrBlank()) {
return explicit.split(',', ';', '\n')
.map { it.trim() }
.filter { it.isNotBlank() }
.distinct()
}
return when (envOrProjectProperty("HICT_DARWIN_PLATFORM_DIR")) {
"darwin_arm64" -> listOf("aarch64-Mac OS X")
"darwin_x86_64" -> listOf("x86_64-Mac OS X")
else -> emptyList()
}
}
val runtimeJhdf5NativePlatforms = selectedRuntimeJhdf5NativePlatforms()
val runtimeJhdf5NativePlatformSet = runtimeJhdf5NativePlatforms.toSet()
val universalJhdf5Runtime = runtimeJhdf5NativePlatforms.isEmpty()
val includeMacX64Jhdf5Runtime = universalJhdf5Runtime || "x86_64-Mac OS X" in runtimeJhdf5NativePlatformSet
val includeMacArm64Jhdf5Runtime = universalJhdf5Runtime || "aarch64-Mac OS X" in runtimeJhdf5NativePlatformSet
fun selectedJhdf5VerificationScope(): String {
val explicit = envOrProjectProperty("HICT_VERIFY_BUNDLED_JHDF5_SCOPE")
?: envOrProjectProperty("hictVerifyBundledJhdf5Scope")
if (!explicit.isNullOrBlank()) {
return explicit.lowercase()
}
return if (runtimeJhdf5NativePlatforms.isNotEmpty()) "runtime" else "universal"
}
val bundledJhdf5VerificationScope = selectedJhdf5VerificationScope()
fun isRuntimeJhdf5NativeFile(fileName: String): Boolean {
val lower = fileName.lowercase()
if (lower == "jhdf5.dll" || lower == "hdf5.dll" || lower == "blosc.dll") {
return true
}
if (lower == "zlib1.dll" || lower == "zlib.dll" || lower == "zstd.dll" || lower == "lz4.dll" || lower == "bz2.dll" || lower == "bzip2.dll") {
return true
}
if (lower == "libjhdf5.so" || lower == "libjhdf5.jnilib") {
return true
}
if (Regex("""libhdf5\.so(?:\..*)?""").matches(lower)) {
return true
}
if (Regex("""libhdf5(?:\.\d+)+\.dylib""").matches(lower) || lower == "libhdf5.dylib") {
return true
}
if (Regex("""lib(?:z|zstd|lz4|bz2|jpeg|aec).*\.so(?:\..*)?""").matches(lower)) {
return true
}
if (Regex("""lib(?:z|zstd|lz4|bz2|jpeg|aec).*\.dylib""").matches(lower)) {
return true
}
if (Regex("""lib(?:zstd|lz4|bz2|jpeg|aec).*\.dll""").matches(lower)) {
return true
}
return Regex("""(?:lib)?h5[a-z0-9_+-]*\.(?:dll|dylib|so(?:\..*)?)""").matches(lower)
}
fun runtimeJhdf5NativesArchiveOrSource(): File? =
runtimeJhdf5NativesArchiveFile.get().asFile.takeIf { it.isFile }
?: bundledJhdf5NativesArchiveFile()
fun requiredJhdf5FilterPluginNames(platformDirectoryName: String): List<String> {
val extension = when {
platformDirectoryName.contains("Windows") -> "dll"
platformDirectoryName.contains("Mac OS X") -> "dylib"
else -> "so"
}
return listOf("bshuf", "lzf", "lz4", "zstd").map { "libh5$it.$extension" }
}
fun allRuntimeJhdf5NativePlatforms(): List<String> = listOf(
"amd64-Linux",
"amd64-Linux-avx2",
"arm64-Linux",
"amd64-Windows",
"amd64-Windows-avx2",
"aarch64-Mac OS X",
"x86_64-Mac OS X"
)
fun validateRequiredJhdf5FilterPlugins(nativeRoot: File, requiredPlatforms: List<String> = allRuntimeJhdf5NativePlatforms()) {
val missing = mutableListOf<String>()
for (platform in requiredPlatforms) {
val platformDir = nativeRoot.resolve(platform)
if (!platformDir.isDirectory) {
missing += "$platform directory"
continue
}
for (plugin in requiredJhdf5FilterPluginNames(platform)) {
if (!platformDir.resolve(plugin).exists()) {
missing += "$platform/$plugin"
}
}
}
if (missing.isNotEmpty()) {
throw GradleException(
"JHDF5 native archive is missing required HDF5 filter plugins needed by HiCT datasets: " +
missing.joinToString(", ")
)
}
}
application {
mainClass.set("ru.itmo.ctlab.hict.hict_server.tools.HictCli")
}
val lombokVersion = "1.18.34"
dependencies {
runtimeOnly("org.webjars:swagger-ui:5.30.2") { isTransitive = false }
// implementation(fileTree("src/main/resources/libs"))
// runtimeOnly(fileTree("src/main/resources/libs/natives"))
val localJhdf5Jar = bundledJhdf5LocalJarFile()
if (localJhdf5Jar != null) {
implementation(files(localJhdf5Jar))
logger.lifecycle("Using bundled JHDF5 jar from ${localJhdf5Jar.absolutePath}")
} else {
val message = if (useMavenJhdf5) {
"HICT_JHDF5_SOURCE_MODE=${jhdf5SourceMode}; using published cisd:jhdf5:19.04.1 from Maven repositories by explicit request."
} else {
"No bundled JHDF5 jar is available at ${bundledJhdf5LocalJarPath} and ${bundledJhdf5DownloadUrl} could not be downloaded; using published cisd:jhdf5:19.04.1 from Maven repositories."
}
if (requireBundledJhdf5) {
throw GradleException(message)
}
logger.lifecycle(message)
implementation("cisd:jhdf5:19.04.1")
}
// https://mvnrepository.com/artifact/cisd/base
implementation("cisd:base:18.09.0")
implementation("org.jetbrains:annotations:24.0.0")
// https://mvnrepository.com/artifact/org.apache.bcel/bcel
implementation("org.apache.bcel:bcel:6.7.0")
compileOnly("org.projectlombok:lombok:$lombokVersion")
annotationProcessor("org.projectlombok:lombok:$lombokVersion")
testCompileOnly("org.projectlombok:lombok:$lombokVersion")
testAnnotationProcessor("org.projectlombok:lombok:$lombokVersion")
implementation("org.slf4j:slf4j-api:$slf4jVersion")
// implementation("org.slf4j:slf4j-nop:1.7.+")
implementation("ch.qos.logback:logback-classic:$logbackVersion")
implementation(platform("io.vertx:vertx-stack-depchain:$vertxVersion"))
implementation("io.vertx:vertx-core")
implementation("io.vertx:vertx-web-client")
implementation("io.vertx:vertx-web-validation")
implementation("io.vertx:vertx-config")
implementation("io.vertx:vertx-web")
implementation("io.vertx:vertx-web-openapi")
implementation("io.vertx:vertx-web-sstore-cookie")
implementation("io.vertx:vertx-json-schema")
implementation("io.vertx:vertx-shell")
implementation("io.vertx:vertx-web-api-contract")
implementation("io.vertx:vertx-uri-template")
implementation("io.vertx:vertx-rx-java3")
implementation("io.vertx:vertx-reactive-streams")
testImplementation("io.vertx:vertx-junit5")
testImplementation("org.junit.jupiter:junit-jupiter:$junitJupiterVersion")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$junitJupiterVersion")
testRuntimeOnly("org.junit.platform:junit-platform-launcher:$junitPlatformVersion")
// https://mvnrepository.com/artifact/org.apache.commons/commons-lang3
implementation("org.apache.commons:commons-lang3:3.22.0")
// Keep transitive runtime parsers/codecs on reviewed patched releases.
// See docs/runtime-dependency-audit.md for advisories and validation scope.
constraints {
implementation("commons-io:commons-io:2.22.0")
implementation("org.apache.commons:commons-compress:1.28.0")
implementation("org.json:json:20260814")
implementation("org.xerial.snappy:snappy-java:1.1.10.12")
}
// https://mvnrepository.com/artifact/org.apache.commons/commons-pool2
implementation("org.apache.commons:commons-pool2:2.11.1")
// https://mvnrepository.com/artifact/org.apache.commons/commons-csv
implementation("org.apache.commons:commons-csv:1.10.0")
// https://mvnrepository.com/artifact/org.scijava/native-lib-loader
implementation("org.scijava:native-lib-loader:2.4.0")
implementation("info.picocli:picocli:4.7.6")
implementation("com.github.samtools:htsjdk:4.1.3")
// The publisher's sole Maven repository is unavailable. Retain the exact
// already-shipped library, with its source/license, on every release platform.
val bigwigJar = file("third_party/bigwig/bigwig-2.0.1.jar")
require(bigwigJar.isFile) { "Missing checked-in BigWig dependency: $bigwigJar" }
val bigwigSha256 = MessageDigest.getInstance("SHA-256")
.digest(bigwigJar.readBytes()).joinToString("") { "%02x".format(it) }
require(bigwigSha256 == "1cf8cdf2746d4160a24aa0d609343189a0d7da9ce7e9ad94caacb8cbaff5f447") {
"BigWig dependency checksum mismatch; restore the reviewed artifact."
}
implementation(files(bigwigJar))
}
java {
sourceCompatibility = JavaVersion.VERSION_19
targetCompatibility = JavaVersion.VERSION_19
}
tasks.withType<ShadowJar> {
archiveClassifier.set("fat")
manifest {
attributes(
mapOf(
"Main-Verticle" to mainVerticleName,
"Main-Class" to "ru.itmo.ctlab.hict.hict_server.tools.HictCli"
)
)
}
mergeServiceFiles()
}
tasks.withType<Test> {
useJUnitPlatform()
System.getProperty("hict.native.test.library")
?.takeIf { it.isNotBlank() }
?.let { systemProperty("hict.native.test.library", it) }
testLogging {
events = setOf(PASSED, SKIPPED, FAILED)
}
}
nativeProcessingVariants.forEach { variant ->
tasks.register<Exec>("compileNativeProcessing${variant.taskSuffix}") {
group = "build"
description = "Build the optional HiCT native processing JNI library (${variant.description}) for the current platform."
val platformDirectory = nativeProcessingPlatformDirectory()
val jniPlatformInclude = nativeProcessingJniIncludeDirectory()
val outputFile = nativeProcessingOutputFile(variant)
val javaHome = file(System.getProperty("java.home"))
val javaInclude = javaHome.resolve("include")
val javaPlatformInclude = jniPlatformInclude?.let { javaInclude.resolve(it) }
val compilerExecutable = nativeProcessingCompilerExecutable()
val compilerFlavor = nativeProcessingCompilerFlavor(compilerExecutable)
val macosDeploymentTarget = providers.environmentVariable("MACOSX_DEPLOYMENT_TARGET")
.orElse(providers.environmentVariable("MACOS_DEPLOYMENT_TARGET"))
.orElse("12.3").get()
if (platformDirectory == "macos_64") {
require(Regex("[0-9]+\\.[0-9]+(\\.[0-9]+)?").matches(macosDeploymentTarget) &&
(macosDeploymentTarget.substringBefore('.').toInt() > 12 ||
(macosDeploymentTarget.substringBefore('.').toInt() == 12 &&
macosDeploymentTarget.split('.')[1].toInt() >= 3))) {
"HiCT requires a macOS deployment target of 12.3 or newer."
}
val legacyTarget = providers.environmentVariable("MACOS_DEPLOYMENT_TARGET").orNull
require(legacyTarget == null || legacyTarget == macosDeploymentTarget) {
"Conflicting MACOSX_DEPLOYMENT_TARGET and MACOS_DEPLOYMENT_TARGET."
}
inputs.property("macosDeploymentTarget", macosDeploymentTarget)
inputs.property("macosInstallName", "@rpath/${outputFile.name}")
}
inputs.file(nativeProcessingSourceFile)
inputs.property("platformDirectory", platformDirectory ?: "unsupported")
inputs.property("jniPlatformInclude", jniPlatformInclude ?: "unsupported")
inputs.property("compilerFlavor", compilerFlavor ?: "unsupported")
inputs.property("variantId", variant.id)
inputs.property("gnuCompileFlags", variant.gnuCompileFlags.joinToString(" "))
inputs.property("msvcCompileFlags", variant.msvcCompileFlags.joinToString(" "))
inputs.property("nativeProcessingOpenMpEnabled", nativeProcessingOpenMpEnabled)
outputs.file(outputFile)
isIgnoreExitValue = true
onlyIf {
platformDirectory != null &&
jniPlatformInclude != null &&
compilerExecutable != null &&
nativeProcessingCompilerSupportsCurrentOs(compilerExecutable) &&
nativeProcessingSourceFile.asFile.isFile &&
javaInclude.isDirectory &&
javaPlatformInclude?.isDirectory == true
}
doFirst {
outputFile.parentFile.mkdirs()
logger.lifecycle("Building HiCT native processing ${variant.id} library: ${outputFile.absolutePath}")
}
val msvcOpenMpFlags = if (nativeProcessingOpenMpEnabled) listOf("/openmp") else listOf("/wd4068")
val gnuOpenMpFlags = if (nativeProcessingOpenMpEnabled) listOf("-fopenmp") else emptyList()
val gnuVariantFlags = if (platformDirectory == "macos_64") emptyList() else variant.gnuCompileFlags
val command = when (compilerFlavor) {
"msvc" -> listOfNotNull(
compilerExecutable,
"/nologo",
"/std:c++17",
"/O2",
"/EHsc",
"/LD",
"/DNOMINMAX",
"/DWIN32_LEAN_AND_MEAN",
"/DHICT_NATIVE_VARIANT=\\\"${variant.id}\\\"",
"/I${javaInclude.absolutePath}",
"/I${javaPlatformInclude?.absolutePath ?: javaInclude.absolutePath}",
nativeProcessingSourceFile.asFile.absolutePath,
"/Fe:${outputFile.absolutePath}"
) + variant.msvcCompileFlags + msvcOpenMpFlags + listOf("/link", "/NOLOGO")
else -> listOfNotNull(
compilerExecutable,
"-std=c++17",
"-O3",
"-fPIC",
"-fvisibility=hidden",
"-shared",
"-DHICT_NATIVE_VARIANT=\"${variant.id}\"",
"-I${javaInclude.absolutePath}",
"-I${javaPlatformInclude?.absolutePath ?: javaInclude.absolutePath}",
"-o",
outputFile.absolutePath,
nativeProcessingSourceFile.asFile.absolutePath
) + gnuVariantFlags + gnuOpenMpFlags +
if (platformDirectory == "macos_64") listOf(
"-mmacosx-version-min=$macosDeploymentTarget",
"-Wl,-install_name,@rpath/${outputFile.name}"
) else emptyList()
}
commandLine(command)
doLast {
val exitValue = executionResult.get().exitValue
if (exitValue != 0) {
outputFile.delete()
emitCiWarning("HiCT native processing ${variant.id} build failed with exit code $exitValue; Java fallback remains available.")
} else if (!outputFile.isFile) {
emitCiWarning("HiCT native processing ${variant.id} build completed but did not produce ${outputFile.absolutePath}; Java fallback remains available.")
}
}
}
}
tasks.register("compileNativeProcessing") {
group = "build"
description = "Build the optional HiCT native processing SSE2 baseline JNI library for the current platform."
dependsOn("compileNativeProcessingSse2")
}
tasks.register("compileNativeProcessingBaseline") {
group = "build"
description = "Compatibility alias for compileNativeProcessingSse2."
dependsOn("compileNativeProcessingSse2")
}
val prepareBundledTools = tasks.register<Exec>("prepareBundledTools") {
group = "build"
description = "Build all bundled analysis/conversion tools; reuse only source-matched, checksummed payloads."
// Deliberately execute the verifier on every invocation: Gradle's output
// timestamps alone cannot prove that a restored external cache is complete.
commandLine(System.getenv("HICT_TOOL_BUILD_PYTHON") ?: if (System.getProperty("os.name").lowercase().contains("win")) "python" else "python3",
"scripts/toolchains/prepare_bundled_tools.py")
}
val completeNativeBuildRequested = gradle.startParameter.taskNames.any {
it.substringAfterLast(":") in listOf("natives", "prepareBundledTools", "build")
}
tasks.register("natives") {
group = "build"
description = "Build HiCT JNI libraries and every bundled conversion/sequence tool for this platform."
dependsOn(prepareBundledTools, "verifyNativeProcessingBuild")
dependsOn(nativeProcessingVariants.map { "compileNativeProcessing${it.taskSuffix}" })
}
tasks.register("verifyNativeProcessingBuild") {
group = "verification"
description = "Warn when optional HiCT native processing variants were not built for the current platform."
dependsOn(nativeProcessingVariants.map { "compileNativeProcessing${it.taskSuffix}" })
doLast {
val platformDirectory = nativeProcessingPlatformDirectory()
if (platformDirectory == null) {
val message = "HiCT native processing is unsupported on this platform; Java fallback remains available."
if (requireNativeProcessingVariants) {
throw GradleException(message)
}
emitCiWarning(message)
return@doLast
}
val missingVariants = mutableListOf<String>()
nativeProcessingVariants.forEach { variant ->
val outputFile = nativeProcessingOutputFile(variant)
if (!outputFile.isFile) {
val message = "HiCT native processing ${variant.id} library is missing at ${outputFile.absolutePath}; this package will use Java fallback for that variant."
missingVariants += "${variant.id} (${outputFile.absolutePath})"
emitCiWarning(message)
} else {
logger.lifecycle("HiCT native processing ${variant.id} library ready: ${outputFile.absolutePath}")
}
}
if ((requireNativeProcessingVariants || completeNativeBuildRequested) && missingVariants.isNotEmpty()) {
throw GradleException(
"Required HiCT native processing variant(s) were not built: ${missingVariants.joinToString()}"
)
}
}
}
tasks.register("describeNativeProcessing") {
group = "help"
description = "Describe optional HiCT native processing library build/load locations."
doLast {
val platformDirectory = nativeProcessingPlatformDirectory()
if (platformDirectory == null) {
println("Native processing platform is unsupported on this machine.")
return@doLast
}
val compilerExecutable = nativeProcessingCompilerExecutable()
println("Native processing source: ${nativeProcessingSourceFile.asFile.absolutePath}")
println("Native processing compiler: ${compilerExecutable ?: "not found"}")
println("Native processing compiler flavor: ${nativeProcessingCompilerFlavor(compilerExecutable) ?: "unsupported"}")
println("Native processing compiler enabled on this OS: ${nativeProcessingCompilerSupportsCurrentOs(compilerExecutable)}")
println("Native processing OpenMP: ${if (nativeProcessingOpenMpEnabled) "requested" else "disabled by default"}")
nativeProcessingVariants.forEach { variant ->
println("Native processing ${variant.id} output: ${nativeProcessingOutputFile(variant).absolutePath}")
}
println("Runtime overrides:")
println(" HICT_NATIVE_PROCESSING=1")
println(" HICT_NATIVE_VARIANT=auto|generic|avx2|avx512")
println(" HICT_NATIVE_VARIANT=baseline, sse2 and x86_64-v3 are accepted as aliases for generic")
println(" HICT_NATIVE_LIBRARY_PATH=${nativeProcessingOutputFile(nativeProcessingVariants.first()).absolutePath}")
println(" HICT_NATIVE_LIBRARY_DIR=${nativeProcessingOutputFile(nativeProcessingVariants.first()).parentFile.absolutePath}")
}
}
tasks.register<JavaExec>("runConversionCli") {
group = "application"
description = "Run conversion CLI (hict-to-mcool / mcool-to-hict subcommands)"
classpath = sourceSets["main"].runtimeClasspath
mainClass.set("ru.itmo.ctlab.hict.hict_server.tools.HictCli")
}
nativeProcessingVariants.forEach { variant ->
tasks.register<JavaExec>("benchmarkNativeProcessing${variant.taskSuffix}") {
group = "verification"
description = "Benchmark Java tile processing against the ${variant.description} native backend."
dependsOn("natives", "compileJava")
onlyIf { nativeProcessingOutputFile(variant).isFile }
classpath = sourceSets["main"].output.classesDirs + sourceSets["main"].compileClasspath
mainClass.set("ru.itmo.ctlab.hict.hict_library.nativeprocessing.NativeProcessingBenchmark")
systemProperty("hict.native.library.dir", nativeProcessingOutputFile(variant).parentFile.absolutePath)
systemProperty("hict.native.variant", variant.id)
listOf(
"hict.native.benchmark.rows",
"hict.native.benchmark.columns",
"hict.native.benchmark.warmup",
"hict.native.benchmark.iterations"
).forEach { propertyName ->
System.getProperty(propertyName)?.let { systemProperty(propertyName, it) }
}
}
}
tasks.register<Test>("testNativeProcessingBaseline") {
group = "verification"
description = "Load the compiled baseline JNI library and verify numeric/rendering parity."
dependsOn("testClasses", "compileNativeProcessingSse2")
testClassesDirs = sourceSets["test"].output.classesDirs
classpath = sourceSets["test"].runtimeClasspath
useJUnitPlatform()
filter { includeTestsMatching("*NativeProcessingServiceTest.compiledNativeLibraryMatchesJavaTileMathWhenProvided") }
val nativeLibrary = nativeProcessingOutputFile(nativeProcessingVariants.first())
systemProperty("hict.native.test.library", nativeLibrary.absolutePath)
doFirst {
if (!nativeLibrary.isFile) throw GradleException("Native parity test requires the compiled library: $nativeLibrary")
}
}
tasks.register("benchmarkNativeProcessingBaseline") {
group = "verification"
description = "Compatibility alias for benchmarkNativeProcessingAvx2."
dependsOn("benchmarkNativeProcessingAvx2")
}
tasks.register("benchmarkNativeProcessing") {
group = "verification"
description = "Benchmark Java tile processing against every native backend built on this machine."
dependsOn(nativeProcessingVariants.map { "benchmarkNativeProcessing${it.taskSuffix}" })
}
tasks.register<JavaExec>("benchmarkNativeProcessingReport") {
group = "verification"
description = "Create a Java/SSE2/AVX2/AVX-512 native processing requests/sec benchmark report with SVG plots."
dependsOn("natives", "compileJava")
classpath = sourceSets["main"].output.classesDirs + sourceSets["main"].compileClasspath
mainClass.set("ru.itmo.ctlab.hict.hict_library.nativeprocessing.NativeProcessingBenchmarkReport")
systemProperty("hict.native.library.dir", nativeProcessingOutputFile(nativeProcessingVariants.first()).parentFile.absolutePath)
systemProperty("hict.native.benchmark.reportDir", layout.buildDirectory.dir("reports/hict-native-benchmark").get().asFile.absolutePath)
listOf(
"hict.native.benchmark.rows",
"hict.native.benchmark.columns",
"hict.native.benchmark.warmup",
"hict.native.benchmark.iterations",
"hict.native.benchmark.variants"
).forEach { propertyName ->
System.getProperty(propertyName)?.let { systemProperty(propertyName, it) }
}
}
tasks.register("benchmark") {
group = "verification"
description = "Run HiCT performance benchmarks available on this machine."
dependsOn("benchmarkNativeProcessingReport")
}
tasks.withType<JavaExec>().configureEach {
doFirst {
environment(
"LD_LIBRARY_PATH",
"\$LD_LIBRARY_PATH:/home/${System.getenv("USER")}/hdf/HDF5-1.14.1-Linux/HDF_Group/HDF5/1.14.1/lib:/home/${
System.getenv(
"USER"
)
}/hdf/HDF5-1.14.1-Linux/HDF_Group/HDF5/1.14.1/lib/plugin"
)
environment(
"HDF5_PLUGIN_PATH",
"/home/${System.getenv("USER")}/hdf/HDF5-1.14.1-Linux/HDF_Group/HDF5/1.14.1/lib/plugin"
)
environment("VERTXWEB_ENVIRONMENT", "dev")
}
}
fun readVersion(): String {
return if (versionFile.exists()) {
versionFile.readText().trim()
} else {
"0.0.0"
}
}
fun writeVersion(version: String) {
versionFile.writeText(version)
}
fun incrementPatchVersion(currentVersion: String): String {
val gitHash = getGitHash(layout.projectDirectory.asFile)
val webuiVer = if (webUIRepositoryDirectory.asFile.exists()) {
val webuiGitHash = getGitHash(webUIRepositoryDirectory.asFile)
"webui_$webuiGitHash"
} else "nowebui"
val semver = currentVersion.substringBefore("-")
val (major, minor, patch) = semver.split(".")
val newPatch = patch.toInt() + 1
return "$major.$minor.$newPatch-$gitHash-$webuiVer"
}
fun getGitHash(repositoryDir: File): String {
val byteOut = ByteArrayOutputStream()
project.exec {
commandLine("git", "rev-parse", "--short=7", "HEAD")
standardOutput = byteOut
workingDir = repositoryDir
}
return String(byteOut.toByteArray()).trim()
}
fun getCurrentJvmRefName(): String? {
val githubRefName = System.getenv("GITHUB_REF_NAME")
if (!githubRefName.isNullOrBlank()) {
return githubRefName.trim()
}