40 lines
1022 B
Groovy
40 lines
1022 B
Groovy
plugins {
|
|
id 'java'
|
|
id 'application'
|
|
id 'com.github.johnrengelman.shadow' version '8.1.1'
|
|
}
|
|
|
|
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
|
|
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'
|
|
}
|
|
}
|