Files
window-axis-innovators-box/build.gradle
tzdwindows 7 e422d31b85 feat(box): 现代化用户界面并添加 jar 文件预览功能
- 使用 FlatDarculaLaf 样式库替换默认样式
- 添加 jar 文件预览功能,使用 CFR 进行反编译
- 更新 build.gradle 文件,添加新依赖项
- 新增 CFROutputSinkFactory 和 JarClassFileSource 类
- 修改主程序启动逻辑,支持 jar 文件预览
2025-02-23 13:31:14 +08:00

169 lines
5.3 KiB
Groovy
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
plugins {
id 'java'
id 'application'
id 'edu.sc.seis.launch4j' version '2.5.4'
id 'org.openjfx.javafxplugin' version '0.1.0'
}
// JDK 版本检查
def requiredJavaVersion = 20
def currentJavaVersion = JavaVersion.current().majorVersion.toInteger()
if (currentJavaVersion != requiredJavaVersion) {
throw new GradleException("构建需要 JDK ${requiredJavaVersion},但当前是 JDK ${currentJavaVersion}。请更换 JDK 环境。")
}
group = 'com.axis.innovators.box'
version = '0.0.1'
repositories {
maven { setUrl("https://maven.aliyun.com/repository/central") }
maven { setUrl("https://maven.aliyun.com/repository/jcenter") }
maven { setUrl("https://maven.aliyun.com/repository/google") }
maven { setUrl("https://maven.aliyun.com/repository/gradle-plugin") }
maven { setUrl("https://maven.aliyun.com/repository/public") }
maven { setUrl("https://jitpack.io") }
maven { setUrl("https://maven.aliyun.com/nexus/content/groups/public/") }
maven { setUrl("https://maven.aliyun.com/nexus/content/repositories/jcenter") }
gradlePluginPortal()
google()
mavenCentral()
}
dependencies {
testImplementation platform('org.junit:junit-bom:5.10.0')
testImplementation 'org.junit.jupiter:junit-jupiter'
implementation 'org.commonmark:commonmark:0.24.0'
implementation 'org.commonjava.googlecode.markdown4j:markdown4j:2.2-cj-1.1'
implementation 'com.google.code.gson:gson:2.8.9'
implementation 'org.apache.logging.log4j:log4j-api:2.20.0'
implementation 'org.apache.logging.log4j:log4j-core:2.20.0'
implementation 'org.apache.logging.log4j:log4j-slf4j-impl:2.20.0'
implementation 'org.ow2.asm:asm:7.1'
implementation 'org.ow2.asm:asm-commons:7.1'
implementation 'org.ow2.asm:asm-analysis:7.1'
implementation 'org.ow2.asm:asm-util:7.0'
implementation 'org.ow2.asm:asm-tree:7.1'
implementation 'org.jsoup:jsoup:1.17.2'
implementation 'com.google.code.gson:gson:2.8.9'
//implementation 'com.formdev:flatlaf:0.26'
implementation 'commons-io:commons-io:2.14.0'
implementation 'com.formdev:flatlaf:3.2.1' // FlatLaf核心
implementation 'com.formdev:flatlaf-extras:3.2.1' // 扩展组件
implementation 'com.formdev:flatlaf-intellij-themes:3.2.1' // 官方主题包
implementation 'org.python:jython-standalone:2.7.3'
implementation 'org.fxmisc.richtext:richtextfx:0.11.0' // 更新后的richtextfx
implementation 'org.bitbucket.mstrobel:procyon-core:0.5.36' // 使用JitPack版本
implementation 'org.bitbucket.mstrobel:procyon-compilertools:0.5.36'
implementation 'com.fifesoft:rsyntaxtextarea:3.3.0'
implementation 'org.apache.commons:commons-compress:1.23.0'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.15.2'
implementation 'org.controlsfx:controlsfx:11.1.2' // 现代化UI组件
implementation 'com.dlsc.formsfx:formsfx-core:11.6.0' // 表单组件
implementation 'net.sourceforge.plantuml:plantuml:8059' // UML支持可选)
implementation 'com.google.code.gson:gson:2.10.1'
implementation 'org.openjfx:javafx-controls:21'
implementation 'org.benf:cfr:0.152'
implementation 'com.github.javaparser:javaparser-core:3.25.1'
}
// 分离依赖项到 libs 目录
task copyDependencies(type: Copy) {
from configurations.runtimeClasspath
into "$buildDir/libs/libs"
}
// 执行我生成jar
jar {
manifest {
attributes 'Main-Class': 'com.axis.innovators.box.Main',
'Class-Path': configurations.runtimeClasspath.files.collect { "libs/$it.name" }.join(' ')
}
dependsOn copyDependencies
}
// 测试配置
test {
useJUnitPlatform()
systemProperty "java.system.class.loader", "com.axis.innovators.box.plugins.BoxClassLoader"
// 确保测试能看到依赖
classpath = files(sourceSets.test.output) +
files("$buildDir/libs/libs") +
configurations.testRuntimeClasspath
}
// 处理开源文档文件
sourceSets {
main {
resources {
exclude '**/*.md'
}
}
openSourceDocs {
resources {
srcDir 'src/main/resources'
include '**/*.md'
}
}
}
tasks.withType(JavaExec).configureEach {
jvmArgs = [
'-Djava.system.class.loader=com.axis.innovators.box.plugins.BoxClassLoader'
]
}
javafx {
version = "21"
modules = [ 'javafx.controls', 'javafx.fxml' ]
}
// 单独打包文档
task packageOpenSourceDocs(type: Jar) {
archiveClassifier = 'docs'
from sourceSets.openSourceDocs.resources
destinationDirectory = file("$buildDir/libs/docs")
}
// 完整的 application 配置
application {
mainClass = 'com.axis.innovators.box.Main'
// 确保运行时参数生效
applicationDefaultJvmArgs = [
"-Djava.system.class.loader=com.axis.innovators.box.plugins.BoxClassLoader",
"-Dloader.library.path=$buildDir/libs/libs",
'-Dfile.encoding=UTF-8'
]
}
// 创建可运行分发
tasks.register('release') {
dependsOn build, packageOpenSourceDocs
doLast {
copy {
from "$buildDir/libs"
into "$buildDir/dist"
include '*.jar'
include 'docs/**'
include 'libs/**'
}
println "Release package ready at: $buildDir/dist"
}
}
// 默认构建任务
build.dependsOn release