我需要从我的依赖项创建一个胖罐子,它不会包含范围内的依赖项compileOnly
dependencies {
api 'org.slf4j:slf4j-api:1.7.26' // this must be in the jar
compileOnly 'it.unimi.dsi:fastutil:8.2.1' // this must not be in the jar
jar {
from {
configurations.compileClasspath.findAll { it.name.endsWith('jar') }.collect { zipTree(it) }
}
}
}
Run Code Online (Sandbox Code Playgroud)
当我构建项目时,两个依赖项都存在于最终的 jar 文件中。我该如何从 fat jar 中排除 fastutil?
我尝试使用runtimeOnly
runtimeOnly 'it.unimi.dsi:fastutil:8.2.1' // this must not be in the jar
Run Code Online (Sandbox Code Playgroud)
但这会导致 fastutil 在编译时无法解析。
我正在运行 Java 16 和 Gradle 7.0.2。
tho*_*est 10
使用configurations.runtimeClasspath而不是configurations.compileClasspath. compileClasspath包含编译所需的所有库,因此fastutil包含在内。runtimeClasspath另一方面从配置中排除库compileOnly。
| 归档时间: |
|
| 查看次数: |
6238 次 |
| 最近记录: |