-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
132 lines (113 loc) · 4.12 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
plugins {
id 'java'
id 'application'
}
repositories {
mavenCentral()
}
compileJava.options.encoding = "UTF-8"
dependencies {
/* Warning: do not use log4j < 2.16 because if a serious (10 of 10 points) vulnerability! */
implementation 'org.slf4j:slf4j-api:2.+'
implementation 'org.slf4j:slf4j-simple:2.+'
// gson
implementation 'com.google.code.gson:gson:2.9.+'
// cactoos (for pure OOP)
implementation 'org.cactoos:cactoos:0.+'
// jetty server
implementation 'org.eclipse.jetty:jetty-server:11.+'
implementation 'org.eclipse.jetty:jetty-servlet:11.+'
compileOnly 'jakarta.servlet:jakarta.servlet-api:5.+'
implementation 'org.eclipse.jetty:jetty-webapp:11.+'
implementation 'org.eclipse.jetty:jetty-proxy:11.+'
implementation 'org.eclipse.jetty.websocket:websocket-jetty-server:11.+'
implementation 'org.eclipse.jetty.websocket:websocket-jetty-client:11.+'
}
test {
useJUnitPlatform()
}
static def getOsName() {
final String osName = System.getProperty("os.name").toLowerCase()
if (osName.contains("linux")) {
return ("Linux")
} else if (osName.contains("windows")) {
return ("Windows_NT") // as %OS%
}
return ("Unsupported OS by the IQD Quantis QRNG device")
}
static def getOsArch() {
return System.properties['os.arch']
// in x86_64 Windows, this returns amd64, which is ok, since in Windows, %PROCESSOR_ARCHITECTURE%=AMD64 and the case does not matter
}
static def getShExt() {
final String osName = System.getProperty("os.name").toLowerCase()
if (osName.contains("windows")) {
return ".bat"
}
else {
return ".sh"
}
}
def JAVA_LIBRARY_PATH_PLACEHOLDER=projectDir.toPath().resolve("dll").resolve(getOsName()+'-'+getOsArch()).toString().replaceAll("\\\\", "/")
// ^^^ this placeholder is used as applicationDefaultJvmArgs when invoking: gradle run
application {
mainClass.set("lv.lumii.qrng.Main")
applicationDefaultJvmArgs = ['-Djava.library.path='+JAVA_LIBRARY_PATH_PLACEHOLDER]
}
startScripts {
applicationName = 'qrng-web-service'
doLast {
unixScript.text = unixScript.text.replace(JAVA_LIBRARY_PATH_PLACEHOLDER, '\$APP_HOME/`uname -s`-`uname -m`')
windowsScript.text = windowsScript.text.replace(JAVA_LIBRARY_PATH_PLACEHOLDER, '%APP_HOME%\\dll\\%OS%-%PROCESSOR_ARCHITECTURE%;%APP_HOME%\\dll\\%OS%-x86;%APP_HOME%\\dll\\%OS%-AMD64;%APP_HOME%\\dll\\%OS%-ARM64')
// ^^^ we add all architectures, since the .bat script can be launched, e.g., in a 32-bit cmd.exe but Java can be 64-bit
}
}
installDist {
doLast {
println "Copying HAProxy configuration into the distribution"
copy {
from(projectDir)
into(destinationDir)
include("cfg/**")
}
println "Copying ca-scripts into the distribution"
copy {
from(projectDir)
into(destinationDir)
include("ca-scripts/**")
}
println "Copying bin-scripts into the distribution"
copy {
from(projectDir)
into(destinationDir)
include("bin-scripts/*.bat")
include("bin-scripts/*.sh")
include("bin-scripts/*.cnf")
}
println "Copying native DLLs/libraries into the distribution"
copy {
from(projectDir)
into(destinationDir)
include("dll/**")
}
println "Generating the self-signed CA key, the server key, and the client key (if they don't exist)"
exec {
commandLine destinationDir.toString() + "/bin-scripts/_gen-keys" + getShExt()
}
}
}
/*installDist {
into(distDirName)
dependsOn startScripts
}*/
run {
//args 'arg'
doFirst {
jvmArgs '-Djava.library.path='+projectDir.toPath().resolve("dll").resolve(getOsName()+'-'+getOsArch())
applicationDefaultJvmArgs = jvmArgs
systemProperty('java.library.path',jvmArgs)
// Uncomment for a lot of debug logging:
// systemProperty('org.slf4j.simpleLogger.defaultLogLevel', 'debug');
// We can also set 'org.slf4j.simpleLogger.logFile' this way.
}
}