我希望从jar文件中排除所有配置文件,因为它们将在配置时提供,并且构建路径中的不同版本可能会产生一些运行时问题。我正在使用以下Gradle构建脚本,但出于某种原因,我仍然可以看到资源目录中存在的任何内容将被复制到构建的Jar中。这意味着出于某种原因,提供的Gradle构建无法按预期工作。
apply plugin: 'distribution'
distributions {
main {
baseName = "${project.name}"
contents {
into('/conf'){
from('src/main/resources')
exclude("application.yml")
}
into('/lib'){
from('build/libs')
}
into('/bin'){
from('../bin')
}
}
}
}
processResources {
# Not sure how I need to point to the resources, so I included both. However, none is working.
exclude('resources/*')
exclude('src/main/resources/*')
}
bootJar{
# Not sure how I need to point to the resources, so I included both. However, none is working.
exclude('resources/*')
exclude('src/main/resources/*')
}
distTar {
dependsOn bootJar
}
tasks.withType(Tar) {
compression = Compression.GZIP
extension = "tar.gz"
}
configurations {
customArch
}
artifacts {
customArch file(distTar.archivePath)
}
2条答案
按热度按时间tkqqtvp11#
我能够通过使用
processResources.enabled = false
将资源从Jar文件中排除,因此构建文件如下所示。nqwrtyyt2#
我发现这个解决方案很适合我:
...其中
logback-spring.xml
位于src/main/resources
中