可执行 JAR(又名“fat JAR”),指单个 JAR 包含除 JRE 外所有运行时依赖
参考 Gradle 官网
代码参考 https://github.com/tothis/java-record/tree/main/ffi
plugins {
java
}
group = "com.example"
version = "0.0.1-SNAPSHOT"
repositories {
mavenCentral()
}
dependencies {
implementation("commons-io:commons-io:2.11.0")
implementation("org.apache.commons:commons-lang3:3.12.0")
// JNA
implementation("net.java.dev.jna:jna:5.10.0")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.2")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
}
tasks.getByName("test") {
useJUnitPlatform()
}
tasks.jar.configure {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
manifest.attributes["Main-Class"] = "com.example.Main"
from(configurations.runtimeClasspath.get().filter { it.name.endsWith("jar") }.map { zipTree(it) })
}



