40 lines
1.0 KiB
Groovy
40 lines
1.0 KiB
Groovy
plugins {
|
||
id 'java'
|
||
id 'application'
|
||
id 'com.gradleup.shadow' version '9.0.2'
|
||
}
|
||
|
||
group = 'cn.lmcw.dht'
|
||
version = project.findProperty('projectVersion') ?: '0.1.0'
|
||
|
||
java {
|
||
sourceCompatibility = JavaVersion.VERSION_11
|
||
targetCompatibility = JavaVersion.VERSION_11
|
||
}
|
||
|
||
application {
|
||
mainClass = 'cn.lmcw.dht.DhtCrawlerExample'
|
||
def libPath = project.findProperty('lib.path') ?: '.'
|
||
applicationDefaultJvmArgs = ["-Djava.library.path=${libPath}"]
|
||
}
|
||
|
||
repositories {
|
||
mavenCentral()
|
||
}
|
||
|
||
// 运行时将 native 库路径传入 JVM(默认指向仓库根 target/release)
|
||
tasks.withType(JavaExec).configureEach {
|
||
def libPath = project.findProperty('lib.path') ?: '../target/release'
|
||
jvmArgs "-Djava.library.path=${libPath}"
|
||
}
|
||
|
||
// Fat JAR(含所有依赖 + Main-Class):执行 `gradle shadowJar` 生成
|
||
shadowJar {
|
||
archiveBaseName = 'dht-crawler-jni-example'
|
||
archiveClassifier = ''
|
||
archiveVersion = version
|
||
manifest {
|
||
attributes 'Main-Class': 'cn.lmcw.dht.DhtCrawlerExample'
|
||
}
|
||
}
|