-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
136 lines (110 loc) · 3.71 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
plugins {
id 'java'
id 'application'
id 'org.javamodularity.moduleplugin' version '1.8.12'
id 'org.openjfx.javafxplugin' version '0.0.13'
id 'org.beryx.jlink' version '2.25.0'
}
group 'net.logandhillon'
version '0.9.7-alpha'
repositories {
mavenCentral()
}
ext {
junitVersion = '5.10.0'
}
sourceCompatibility = '21'
targetCompatibility = '21'
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
application {
mainModule = 'net.logandhillon.icx'
mainClass = 'net.logandhillon.icx.ICX'
}
javafx {
version = '22-ea+11'
modules = ['javafx.controls', 'javafx.fxml']
}
dependencies {
testImplementation("org.junit.jupiter:junit-jupiter-api:${junitVersion}")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${junitVersion}")
implementation("org.apache.logging.log4j:log4j-core:2.24.0")
compileOnly('org.jspecify:jspecify:1.0.0') // fixes "error: module not found: org.jspecify"
implementation("org.bouncycastle:bcprov-jdk15on:1.70")
implementation("org.bouncycastle:bcpkix-jdk15on:1.70")
}
test {
useJUnitPlatform()
}
gradle.projectsLoaded {
def runDir = file("$rootDir/run")
def clientDir = file("$runDir/client")
def serverDir = file("$runDir/server")
if (!runDir.exists()) runDir.mkdirs()
if (!clientDir.exists()) clientDir.mkdirs()
if (!serverDir.exists()) serverDir.mkdirs()
}
def jdkDir = file("${buildDir}/jdks")
def jdkVersion = "21"
def downloadJdk(String jdkUrl, File destinationDir) {
destinationDir.mkdirs()
def jdkArchive = new File(destinationDir, jdkUrl.substring(jdkUrl.lastIndexOf('/') + 1))
if (!jdkArchive.exists()) {
println "Downloading JDK from: $jdkUrl"
new URL(jdkUrl).withInputStream { downloadStream ->
jdkArchive.withOutputStream { outputStream ->
outputStream << downloadStream
}
}
println "Downloaded: ${jdkArchive.name}"
}
def tempDir = new File(destinationDir, "temp")
if (jdkArchive.name.endsWith('.zip')) {
copy {
from zipTree(jdkArchive)
into tempDir
}
} else if (jdkArchive.name.endsWith('.tar.gz')) {
copy {
from tarTree(resources.gzip(jdkArchive))
into tempDir
}
}
def extractedDir = tempDir.listFiles()?.find { it.isDirectory() }
if (extractedDir) {
def finalDir = new File(destinationDir, "bin")
extractedDir.renameTo(finalDir)
}
delete(tempDir)
}
task downloadJdks {
doLast {
downloadJdk("https://corretto.aws/downloads/latest/amazon-corretto-${jdkVersion}-x64-linux-jdk.tar.gz", file("${jdkDir}/linux"))
downloadJdk("https://corretto.aws/downloads/latest/amazon-corretto-${jdkVersion}-x64-windows-jdk.zip", file("${jdkDir}/win"))
downloadJdk("https://corretto.aws/downloads/latest/amazon-corretto-${jdkVersion}-aarch64-macos-jdk.tar.gz", file("${jdkDir}/mac-aarch64"))
downloadJdk("https://corretto.aws/downloads/latest/amazon-corretto-${jdkVersion}-x64-macos-jdk.tar.gz", file("${jdkDir}/mac-x64"))
}
}
jlink {
imageZip = project.file("${buildDir}/distributions/${name}-${version}.zip")
options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages', '--ignore-signing-information']
launcher {
name = 'ICX'
}
targetPlatform("linux") {
jdkHome = file("${jdkDir}/linux/bin")
}
targetPlatform("win") {
jdkHome = file("${jdkDir}/win/bin")
}
targetPlatform("mac-aarch64") {
jdkHome = file("${jdkDir}/mac-aarch64/bin/Contents/Home")
}
targetPlatform("mac-x64") {
jdkHome = file("${jdkDir}/mac-x64/bin/Contents/Home")
}
}
jlinkZip {
group = 'distribution'
}