-
Notifications
You must be signed in to change notification settings - Fork 12
/
build.gradle
108 lines (94 loc) · 3.42 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
plugins {
id "application"
id "java"
id "org.beryx.jlink" version "2.26.0"
id "org.openjfx.javafxplugin" version "0.1.0"
id "com.gluonhq.gluonfx-gradle-plugin" version "1.0.22"
}
group "com.icuxika"
version "1.0.0"
repositories {
mavenCentral()
}
application {
applicationName = "JavaFXSample"
mainModule.set("sample")
mainClass.set("com.icuxika.MainApp")
applicationDefaultJvmArgs = [
// ZGC
"-XX:+UseZGC",
// 当遇到空指针异常时显示更详细的信息
"-XX:+ShowCodeDetailsInExceptionMessages",
"-Dsun.java2d.opengl=true",
// 不添加此参数,打包成exe后,https协议的网络图片资源无法加载
"-Dhttps.protocols=TLSv1.1,TLSv1.2"
]
}
javafx {
version = "21"
modules = ["javafx.controls", "javafx.graphics", "javafx.fxml", "javafx.swing", "javafx.media", "javafx.web"]
}
dependencies {
implementation("io.github.palexdev:materialfx:11.16.1")
implementation("org.slf4j:slf4j-api:2.0.12")
implementation("ch.qos.logback:logback-classic:1.5.3")
}
jlink {
options.set(List.of("--strip-debug", "--compress", "zip-9", "--no-header-files", "--no-man-pages"))
launcher {
name = application.applicationName
imageName.set(application.applicationName)
}
imageZip.set(project.file("${project.getLayout().getBuildDirectory().get()}/image-zip/JavaFXSample.zip"))
jpackage {
outputDir = "build-package"
imageName = application.applicationName
skipInstaller = false
installerName = application.applicationName
appVersion = version.toString()
if (org.gradle.internal.os.OperatingSystem.current().windows) {
icon = "src/main/resources/application.ico"
installerOptions += ["--win-dir-chooser", "--win-menu", "--win-shortcut", "--win-menu-group", application.applicationName]
}
if (org.gradle.internal.os.OperatingSystem.current().macOsX) {
icon = "src/main/resources/application.icns"
}
if (org.gradle.internal.os.OperatingSystem.current().linux) {
icon = "src/main/resources/application.png"
installerType = "deb"
installerOptions += ["--linux-deb-maintainer", "[email protected]", "--linux-menu-group", application.applicationName, "--linux-shortcut"]
}
}
}
tasks.withType(JavaCompile).configureEach {
options.encoding = "UTF-8"
}
// https://github.com/gluonhq/substrate/issues/1232
// 修改icon 不要改变文件名称 src\windows\assets\icon.ico
mainClassName = "com.icuxika.MainApp"
gluonfx {
bundlesList = [
"LanguageResource",
"LanguageResource_en",
"LanguageResource_zh_CN"
]
if (org.gradle.internal.os.OperatingSystem.current().macOsX) {
compilerArgs = ["-Dsvm.platform=org.graalvm.nativeimage.Platform\$MACOS_AMD64"]
}
}
task printDependentJarsList {
doLast {
println("------------------------------------------------------------")
println(configurations.getByName("runtimeClasspath").asPath)
println("------------------------------------------------------------")
}
}
// 拷贝项目依赖的jar包到指定目录
task copyDependencies() {
doLast {
copy {
from(configurations.getByName("runtimeClasspath"))
into("${project.getLayout().getBuildDirectory().get()}/modules")
}
}
}