@@ -3,8 +3,7 @@ plugins {
33 id ' application'
44 id ' org.javamodularity.moduleplugin' version ' 1.8.12'
55 id ' org.openjfx.javafxplugin' version ' 0.1.0'
6- id ' org.beryx.jlink' version ' 2.25.0'
7- id ' com.gluonhq.gluonfx-gradle-plugin' version ' 1.0.23'
6+ id ' org.beryx.jlink' version ' 3.1.5'
87 id ' org.gradlex.extra-java-module-info' version ' 1.12'
98}
109
@@ -56,21 +55,24 @@ ext {
5655 guava : ' 33.2.1-jre' ,
5756 lang3 : ' 3.16.0' ,
5857 javaWebSocket : ' 1.6.0' ,
59- slf4jSimple : ' 2.1.0-alpha1 ' ,
58+ tinylog : ' 2.7.0 ' ,
6059 blockingMap : ' 0.91' ,
6160 vlcjJavaFX : ' 1.2.0' ,
6261 vlcj : ' 4.8.3' ,
6362 filelize : ' 0.9.5' ,
6463 m3uParser : ' 1.4.0' ,
6564 okhttp : ' 5.0.0-alpha.14' ,
66- hutoolAll : ' 5.8.27 ' ,
65+ hutool : ' 5.8.43 ' ,
6766 jsoup : ' 1.15.3' ,
6867 jsoupXpath : ' 2.5.1' ,
6968 json : ' 20250517' ,
7069 zxingCore : ' 3.5.3' ,
7170 twelvemonkeys : ' 3.12.0' ,
7271 emojiJava : ' 5.1.1' ,
7372 mpv : ' 0.1.3' ,
73+ graal : ' 24.2.2' ,
74+ kotlinxCoroutines : ' 1.8.1' ,
75+ guice : ' 7.0.0' ,
7476 lombok : ' 1.18.34' ,
7577 junit : ' 5.9.2'
7678 ]
@@ -84,14 +86,19 @@ dependencies {
8486 implementation " com.google.guava:guava:${ dv.guava} "
8587 implementation " org.apache.commons:commons-lang3:${ dv.lang3} "
8688 implementation " org.java-websocket:Java-WebSocket:${ dv.javaWebSocket} "
87- implementation " org.slf4j:slf4j-simple:${ dv.slf4jSimple} "
89+ implementation " org.tinylog:slf4j-tinylog:${ dv.tinylog} "
90+ implementation " org.tinylog:tinylog-impl:${ dv.tinylog} "
8891 implementation " com.github.sarveswaran-m:util.concurrent.blockingMap:${ dv.blockingMap} "
8992 implementation " uk.co.caprica:vlcj:${ dv.vlcj} "
9093 implementation " uk.co.caprica:vlcj-javafx:${ dv.vlcjJavaFX} "
9194 implementation " io.github.filelize:filelize-java:${ dv.filelize} "
9295 implementation " com.github.bjoernpetersen:m3u-parser:${ dv.m3uParser} "
9396 implementation " com.squareup.okhttp3:okhttp:${ dv.okhttp} "
94- implementation " cn.hutool:hutool-all:${ dv.hutoolAll} "
97+ implementation " cn.hutool:hutool-core:${ dv.hutool} "
98+ implementation " cn.hutool:hutool-crypto:${ dv.hutool} "
99+ implementation " cn.hutool:hutool-http:${ dv.hutool} "
100+ implementation " cn.hutool:hutool-json:${ dv.hutool} "
101+ implementation " cn.hutool:hutool-system:${ dv.hutool} "
95102 implementation " org.jsoup:jsoup:${ dv.jsoup} "
96103 implementation " cn.wanghaomiao:JsoupXpath:${ dv.jsoupXpath} "
97104 implementation " org.json:json:${ dv.json} "
@@ -102,7 +109,13 @@ dependencies {
102109 implementation(" io.github.kknifer7:mpv:${ dv.mpv} " ) {
103110 // vlcj依赖中已包含模块化的高版本jna,所以这里排除
104111 exclude group : ' net.java.dev.jna'
112+ // 排除日志依赖,统一使用tinylog
113+ exclude module : ' slf4j-simple'
105114 }
115+ implementation " org.graalvm.polyglot:polyglot:${ dv.graal} "
116+ implementation " org.graalvm.js:js-language:${ dv.graal} "
117+ implementation " org.jetbrains.kotlinx:kotlinx-coroutines-core:${ dv.kotlinxCoroutines} "
118+ implementation " com.google.inject:guice:${ dv.guice} "
106119
107120 compileOnly " org.projectlombok:lombok:${ dv.lombok} "
108121 annotationProcessor " org.projectlombok:lombok:${ dv.lombok} "
@@ -120,11 +133,15 @@ extraJavaModuleInfo {
120133 patchRealModule()
121134 exportAllPackages()
122135 }
123- // okhttp
136+ // okhttp、kotlin
124137 module(' org.jetbrains.kotlin:kotlin-stdlib' , ' kotlin.stdlib' ) {
125138 patchRealModule()
126139 exportAllPackages()
127140 }
141+ module(' org.jetbrains:annotations' , ' annotations' ) {
142+ patchRealModule()
143+ exportAllPackages()
144+ }
128145 // filelize
129146 module(' io.github.filelize:filelize-java' , ' filelize' ) {
130147 requires ' org.slf4j'
@@ -144,24 +161,28 @@ extraJavaModuleInfo {
144161 // 解决google guava相关的编译错误
145162 automaticModule(' com.google.guava:listenablefuture' , ' listenablefutureAvoidConflict' )
146163 automaticModule(' com.google.code.findbugs:jsr305' , ' jsr305' )
147- // okhttp
148- automaticModule(' org.jetbrains:annotations' , ' annotations' )
149164 // JsoupXpath
150165 automaticModule(' cn.wanghaomiao:JsoupXpath' , ' jsoupXpath' )
151166 // mpv
152167 automaticModule(' io.github.kknifer7:mpv' , ' mpv' )
153168 // emoji-java
154169 automaticModule(' com.vdurmont:emoji-java' , ' emojiJava' )
170+ // guice
171+ automaticModule(' aopalliance:aopalliance' , ' aopalliance' )
155172}
156173
157174test {
158175 useJUnitPlatform()
159176}
160177
178+ def isPackaging = gradle. startParameter. taskNames. contains(' jpackage' )
161179sourceSets {
162180 main {
163181 resources {
164182 srcDirs = [' src/main/resources' ]
183+ if (isPackaging) {
184+ exclude ' tinylog-dev.properties'
185+ }
165186 }
166187 }
167188}
@@ -183,18 +204,23 @@ run {
183204 ' --add-exports=javafx.base/com.sun.javafx.event=org.controlsfx.controls' ,
184205 ' --add-opens=org.controlsfx.controls/org.controlsfx.control=io.knifer.freebox' ,
185206 ' --add-opens=javafx.graphics/javafx.scene=org.controlsfx.controls' ,
186- ' --add-opens=javafx.graphics/javafx.scene.text=cn.hutool' ,
187- ' --add-opens=javafx.graphics/javafx.scene.text=io.knifer.merged.module'
207+ ' --add-opens=javafx.graphics/javafx.scene.text=cn.hutool.core' ,
208+ ' --add-opens=org.tinylog.api/org.tinylog.configuration=io.knifer.freebox' ,
209+ ' -Dpolyglot.engine.WarnInterpreterOnly=false'
188210 ]
189- }
190-
191- gluonfx {
192- graalvmHome = ' E:\\ StudyTools\\ graalvm-ce-java17-22.3.2'
211+ if (isPackaging) {
212+ jvmArgs + = [
213+ ' --add-opens=javafx.graphics/javafx.scene.text=io.knifer.merged.module' ,
214+ ' -Dfreebox.profile=PROD'
215+ ]
216+ } else {
217+ jvmArgs + = ' -Dfreebox.profile=DEV'
218+ }
193219}
194220
195221def appDisplayName = ' FreeBox'
196222jlink {
197- imageZip = project. file(" ${ buildDir } /distributions/app-${ javafx.platform.classifier} .zip" )
223+ imageZip = project. file(resolveBuildDir( " /distributions/app-${ javafx.platform.classifier} .zip" ) )
198224 options = [' --strip-debug' , ' --compress' , ' 2' , ' --no-header-files' , ' --no-man-pages' ]
199225 launcher {
200226 name = appDisplayName
@@ -212,8 +238,18 @@ jlink {
212238 requires ' org.json'
213239 requires ' com.google.gson'
214240 requires ' ipcsocket'
241+ requires ' kotlin.stdlib'
242+ requires ' jakarta.inject'
215243 uses ' cn.hutool.core.convert.Converter'
216244 }
245+ tasks. named(' jlink' ) {
246+ doLast {
247+ copy {
248+ from " ${ projectDir} /resources/app-assets"
249+ into imageDir
250+ }
251+ }
252+ }
217253 tasks. named(' jpackage' ) {
218254 doFirst {
219255 delete " ${ projectDir} /jpackage_temp"
@@ -229,7 +265,7 @@ jlink {
229265 vendor = ' knifer'
230266 installerOptions = [
231267 ' --verbose' ,
232- ' --temp' , ' jpackage_temp' ,
268+ ' --temp' , ' jpackage_temp'
233269 ]
234270 if (org.gradle.internal.os.OperatingSystem . current(). windows) {
235271 icon = " ${ projectDir} /resources/logo/FreeBox.ico"
@@ -269,7 +305,12 @@ jlinkZip {
269305 group = ' distribution'
270306}
271307
272- static def getCurrentArch () {
308+
309+ private String resolveBuildDir (String dir ) {
310+ return layout. buildDirectory. get(). dir(dir)
311+ }
312+
313+ private static def getCurrentArch () {
273314 String arch = System . getProperty(" os.arch" )
274315
275316 switch (arch) {
@@ -280,4 +321,4 @@ static def getCurrentArch() {
280321 default :
281322 return arch
282323 }
283- }
324+ }
0 commit comments