gpt4 book ai didi

spring-boot - 从 springBoots `bootJar` gradle 任务中排除特定依赖项

转载 作者:行者123 更新时间:2023-12-03 02:53:04 24 4
gpt4 key购买 nike

我需要从 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()
}

最佳答案

我也得到了来自 Andy Wilkinson 的答复在 spring boot gitter channel 中,它的工作原理略有不同,但设法实现了相似的效果。

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)
}
}

谢谢安迪 =)

关于spring-boot - 从 springBoots `bootJar` gradle 任务中排除特定依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51048644/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com