-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.gradle
126 lines (110 loc) · 4.49 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
import org.gradle.internal.os.OperatingSystem
plugins {
id 'application'
id 'org.openjfx.javafxplugin' version '0.0.10'
id 'org.beryx.runtime' version '1.12.7'
id 'com.github.johnrengelman.shadow' version '7.0.0'
}
group 'com.icuxika'
version '1.0.0'
application {
applicationName = 'IMFrameworkFX'
mainClass.set('com.icuxika.Launcher')
applicationDefaultJvmArgs = [
'-XX:+UseZGC',
'-XX:+ShowCodeDetailsInExceptionMessages',
'-Dsun.java2d.opengl=true',
// 不添加此参数,打包成exe后,https协议的网络图片资源无法加载
'-Dhttps.protocols=TLSv1.1,TLSv1.2',
'--add-exports=javafx.controls/com.sun.javafx.scene.control=ALL-UNNAMED',
'--add-exports=javafx.controls/com.sun.javafx.scene.control.behavior=ALL-UNNAMED',
'--add-exports=javafx.graphics/com.sun.javafx.util=ALL-UNNAMED',
'--add-exports=javafx.graphics/com.sun.javafx.stage=ALL-UNNAMED',
'--add-exports=javafx.graphics/com.sun.javafx.scene=ALL-UNNAMED',
'--add-exports=javafx.base/com.sun.javafx.event=ALL-UNNAMED',
'--add-opens=java.base/java.lang.reflect=ALL-UNNAMED'
]
}
javafx {
version = '17'
modules = ['javafx.controls', 'javafx.fxml', 'javafx.swing', 'javafx.media']
}
repositories {
mavenCentral()
}
dependencies {
implementation('org.slf4j:slf4j-api:1.7.36')
implementation('org.apache.logging.log4j:log4j-slf4j-impl:2.19.0')
implementation('org.apache.logging.log4j:log4j-api:2.19.0')
implementation('org.apache.logging.log4j:log4j-core:2.19.0')
// log4j yaml config depends on jackson
implementation('com.fasterxml.jackson.core:jackson-core:2.13.4')
implementation('com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.13.4')
// IDEA setting -> build -> gradle -> set Building and run using: IDEA
// IDEA setting -> build -> gradle -> set Run tests using: IDEA
testImplementation('org.junit.jupiter:junit-jupiter-api:5.9.0')
testImplementation('org.junit.jupiter:junit-jupiter-engine:5.9.0')
implementation('org.kordamp.ikonli:ikonli-javafx:12.3.1')
implementation('org.kordamp.ikonli:ikonli-fontawesome5-pack:12.3.1')
implementation('com.squareup.okhttp3:okhttp:4.10.0')
implementation('com.google.code.gson:gson:2.9.0')
implementation('com.google.zxing:javase:3.5.0')
}
test {
useJUnitPlatform()
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
// options.compilerArgs << '-Xlint:deprecation' << '-Xlint:unchecked'
}
// 使用 https://badass-runtime-plugin.beryx.org/releases/latest/
// 插件 Badass-Runtime plugin 需要将主类单独抽离出来,这里使用Launcher作为启动类,不然的话,会提示没有加载Java FX组件
runtime {
options.set(['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages'])
modules.set([
'java.desktop',
'java.xml',
'jdk.unsupported',
'jdk.jfr',
'jdk.unsupported.desktop',
'java.datatransfer',
'java.scripting',
'java.rmi',
'java.sql',
'java.naming',
'java.compiler',
'java.logging',
'java.management'])
launcher {
// 如果构建后无法启动并且无法知晓异常时,可以将此参数配置为false,
// 然后执行 gradle runtime,会得到bat方式的可执行程序,在cmd中运行对应bat,可以看到对应异常
noConsole = true
}
jpackage {
imageName = applicationName
def currentOS = OperatingSystem.current()
if (currentOS.isMacOsX()) {
imageOptions.addAll(['--icon', 'src/main/resources/application.icns'])
}
if (currentOS.isWindows()) {
imageOptions.addAll(['--icon', 'src/main/resources/application.ico'])
installerOptions.addAll([
'--win-dir-chooser',
'--win-menu',
'--win-shortcut',
'--install-dir',
applicationName
])
}
if (currentOS.isLinux()) {
imageOptions.addAll(['--icon', 'src/main/resources/application.png'])
installerOptions.addAll([
'--linux-deb-maintainer',
'--linux-menu-group',
applicationName,
'--linux-shortcut'
])
}
}
}