Hem*_*roc 4 executable-jar dependency-management gradle spring-boot
我需要从 springBoots bootJar
gradle 任务中排除特定的依赖项(类似于 maven 中提供的范围)。
我尝试了自定义配置,但它dependency-which-should-not-be-in-bootJar
仍然包含在生成的 jar 中。
configurations{
provided
implementation.extendsFrom provided
}
dependencies {
// ...
provided "dependency-which-should-not-be-in-bootJar"
}
jar {
from configurations.compile - configurations.provided
from configurations.runtime
}
bootJar {
from configurations.compile - configurations.provided
from configurations.runtime
launchScript()
}
Run Code Online (Sandbox Code Playgroud)
我还在spring boot gitter 频道中得到了Andy Wilkinson的回答,其工作原理略有不同,但设法实现类似的效果。
configurations {
custom
runtime.extendsFrom custom
}
dependencies {
compile 'org.springframework.boot:spring-boot-starter-web'
custom 'com.h2database:h2'
}
bootJar {
exclude {
configurations.custom.resolvedConfiguration.files.contains(it.file)
}
}
Run Code Online (Sandbox Code Playgroud)
谢谢你安迪 =)
归档时间: |
|
查看次数: |
6169 次 |
最近记录: |