I've multiple Microservices with varied 3rd party dependencies, currently using default spring boot docker layers which copies all the dependencies to same dependencies layer. However I want to split the dependencies into core and dependencies layer. core layer contains spring-boot-starter-webflux
, spring-boot-starter-actuator
, spring-cloud-starter-sleuth
and rest of the dependencies like jpa, streams etc goes into dependencies layer.
bootJar {
enabled = true
archiveFileName = "${archiveBaseName.get()}.${archiveExtension.get()}"
layered {
application {
intoLayer("spring-boot-loader") {
include "org/springframework/boot/loader/**"
}
intoLayer("application")
}
dependencies {
intoLayer("application") {
includeProjectDependencies()
}
intoLayer("snapshot-dependencies") {
include "*:*:*SNAPSHOT"
}
intoLayer("core") {
include "org.springframework.boot:spring-boot-starter-webflux:*"
include "org.springframework:spring-webflux:*"
include "org.springframework.boot:spring-boot-starter-actuator:*"
}
intoLayer("dependencies")
}
layerOrder = ["core", "dependencies", "spring-boot-loader", "snapshot-dependencies", "application"]
}
}
The problem here is layering include doesn't include dependencies transitively. For example spring-webflux
doesn't include reactor
, netty
transitively. I need to mention the dependencies manually. Is there a way to include the dependencies transitively only for core
layer and not for application
or snapshot
and rest of the dependencies to dependencies
.