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
|
plugins {
application
jacoco
id("jacoco-report-aggregation")
id("com.google.osdetector") version "1.7.3"
id("com.adarshr.test-logger") version "4.0.0"
}
repositories {
mavenCentral()
}
dependencies {
// First see if Nix gave us a path, then try the ext build, then the bundled.
if (System.getenv("WOLFCRYPT_LIB_PATH") != null) {
implementation(files(System.getenv("WOLFCRYPT_LIB_PATH") + "/wolfcrypt-jni.jar"));
} else if (file("$rootDir/ext/wolfcrypt-jni/lib/wolfcrypt-jni.jar").exists()) {
implementation(files("$rootDir/ext/wolfcrypt-jni/lib/wolfcrypt-jni.jar"))
} else {
implementation(files("$rootDir/ext/wolfcrypt-jni.jar"))
}
implementation(project(":common"))
testImplementation(platform("org.junit:junit-bom:5.10.2"))
testImplementation("org.junit.jupiter:junit-jupiter")
testImplementation("org.junit-pioneer:junit-pioneer:2.2.0")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}
java {
sourceCompatibility = JavaVersion.VERSION_15
}
application {
applicationName = "ECTesterStandalone"
mainClass = "cz.crcs.ectester.standalone.ECTesterStandalone"
version = "0.3.3"
}
tasks.named<Test>("test") {
val resultsDir = layout.buildDirectory.dir("results").get().asFile;
doFirst {
resultsDir.mkdirs();
}
useJUnitPlatform()
// Report is always generated after tests run
finalizedBy(tasks.named<JacocoReport>("testCodeCoverageReport"))
if (JavaVersion.current() > JavaVersion.VERSION_1_8 && JavaVersion.current() < JavaVersion.VERSION_22) {
jvmArgs("--add-exports", "jdk.crypto.ec/sun.security.ec=ALL-UNNAMED"
)
} else if (JavaVersion.current() >= JavaVersion.VERSION_22) {
jvmArgs("--add-exports", "java.base/sun.security.ec=ALL-UNNAMED")
}
jvmArgs("-Xmx8G", "-Xms2G")
// Add our preload to tests, so they do not need to start another process.
environment(
"LD_PRELOAD", "$rootDir/standalone/src/main/resources/cz/crcs/ectester/standalone/libs/jni/lib_preload.so"
)
// Add a path where we will store our test results.
environment(
"RESULT_PATH", resultsDir.absolutePath
)
}
tasks.named<JacocoReport>("testCodeCoverageReport") {
reports {
html.required = true
html.outputLocation.set(layout.buildDirectory.dir("reports/jacoco/test/html"))
xml.required = true
xml.outputLocation.set(layout.buildDirectory.file("reports/jacoco/test/jacocoTestReport.xml"))
}
}
testlogger {
theme = com.adarshr.gradle.testlogger.theme.ThemeType.MOCHA
showStandardStreams = true
}
tasks.withType<JavaCompile> {
if (JavaVersion.current() > JavaVersion.VERSION_1_8 && JavaVersion.current() < JavaVersion.VERSION_22) {
options.compilerArgs.addAll(arrayOf(
"--add-modules", "jdk.crypto.ec",
"--add-exports", "jdk.crypto.ec/sun.security.ec=ALL-UNNAMED"
))
} else if (JavaVersion.current() >= JavaVersion.VERSION_22) {
options.compilerArgs.addAll(arrayOf(
"--add-modules", "java.base",
"--add-exports", "java.base/sun.security.ec=ALL-UNNAMED"
))
}
}
tasks.register<Exec>("libs") {
workingDir("src/main/resources/cz/crcs/ectester/standalone/libs/jni")
environment("PROJECT_ROOT_PATH", rootDir.absolutePath)
val libName = findProperty("libName") ?: "all"
if ( libName == "" ) {
println("Building all libraries")
} else {
println("Buidling ${libName}")
}
if (osdetector.os == "windows") {
commandLine("makefile.bat", "/c", libName)
} else if (osdetector.os == "linux") {
commandLine("make", "-f", "Makefile.ext", "-k", "-B", libName)
}
}
tasks.register<Jar>("uberJar") {
archiveFileName = "ECTesterStandalone.jar"
duplicatesStrategy = DuplicatesStrategy.WARN
from(sourceSets.main.get().output)
manifest {
attributes["Main-Class"] = application.mainClass
if (JavaVersion.current() > JavaVersion.VERSION_1_8) {
attributes["Add-Exports"] = "jdk.crypto.ec/sun.security.ec"
}
}
dependsOn(configurations.runtimeClasspath)
from({
configurations.runtimeClasspath.get().filter { it.name.endsWith("jar") }.map { zipTree(it).matching { exclude("META-INF/*.DSA", "META-INF/*.SF", "META-INF/*.RSA", "META-INF/versions/*/module-info.class") } }
})
}
|