-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle.kts
94 lines (85 loc) · 2.96 KB
/
build.gradle.kts
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
plugins {
java
application
id("org.beryx.jlink") version "3.0.1"
id("de.undercouch.download") version "5.6.0"
}
group = "io.gitlab.jfronny"
version = "1.0"
application {
mainClass.set("io.gitlab.jfronny.javagi.example.Main")
mainModule.set("io.gitlab.jfronny.javagi.example")
}
repositories {
mavenCentral()
}
dependencies {
implementation("io.github.jwharm.javagi:adw:0.11.2") // or gtk for pure GTK
}
val os = org.gradle.internal.os.OperatingSystem.current()!!
val appName = "JavaGI Multiplatform Example"
if (os.isWindows) {
val downloadNatives by tasks.registering(de.undercouch.gradle.tasks.download.Download::class) {
src("https://github.com/jwharm/java-gi/releases/download/libraries/natives-adw.zip") // or natives-gtk for pure GTK
dest(layout.buildDirectory.file("natives.zip"))
overwrite(false)
}
tasks.jpackageImage {
dependsOn(downloadNatives)
doLast {
copy {
from(zipTree(downloadNatives.get().dest))
into(layout.buildDirectory.dir("jpackage/$appName/app"))
}
copy {
from(zipTree(downloadNatives.get().dest))
into(layout.buildDirectory.dir("jpackage/$appName/runtime/bin"))
}
}
}
}
fun computeDebugVersion(): String {
val time = System.currentTimeMillis() / 1000 / 60 / 5 // 5 minute intervals
// installer versions MUST be [0-255].[0-255].[0-65535]
// in other words, 8,8,16 bits
val major = (time / (256 * 65536))
val minor = (time / 65536) % 256
val patch = time % 65536
return "$major.$minor.$patch"
}
jlink {
addOptions(
"--strip-debug",
"--no-header-files",
"--no-man-pages",
"--verbose"
)
launcher {
name = appName
}
jpackage {
vendor = "Some Corp"
jvmArgs.addAll(listOf(
"--enable-native-access=org.gnome.gtk",
"--enable-native-access=org.gnome.glib",
"--enable-native-access=org.gnome.gobject",
"--enable-native-access=org.gnome.gio",
"--enable-native-access=org.gnome.adw"
))
if(os.isMacOsX) {
//installerType = "app-image"
} else if(os.isWindows) {
installerType = "msi" // Only generate the msi installer, since the behavior for MSIs and EXEs differs
installerOptions.addAll(listOf(
"--win-per-user-install",
"--win-dir-chooser",
"--win-menu",
"--win-upgrade-uuid", "1d2e433e-f2e1-43bc-9cd4-60d1ec6b7833" // Update this UUID if you fork the project!!!
))
appVersion = computeDebugVersion() // ensure every debug build has a unique version to allow updates. ONLY do this for debug builds (and ensure they use a different UUID!)
//imageOptions.add("--win-console") // Enable this for debugging
} else {
//installerType = "deb"
}
}
}