Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sample of how to configure Spring Boot's layered jar support for multi-module build that includes your own libs
subprojects { subproject ->
// ...
plugins.withId('org.springframework.boot') {
springBoot {
bootJar {
layered {
// application follows Boot's defaults
application {
intoLayer("spring-boot-loader") {
include "org/springframework/boot/loader/**"
}
intoLayer("application")
}
// for dependencies we ensure that our own libraries are put into a separate layer
dependencies {
intoLayer("libs-dependencies") {
include "nl.trifork:*:*"
}
intoLayer("dependencies")
}
layerOrder = ["dependencies", "spring-boot-loader", "libs-dependencies", "application"]
}
}
buildInfo {
properties {
// ensure builds result in the same artifact when nothing's changed:
time = null
}
}
}
}
}
@JWThewes
Copy link

JWThewes commented Jun 24, 2020

Do you have any idea if this is possible with maven?

@jkuipers
Copy link
Author

jkuipers commented Jun 24, 2020

The Maven plugin provides the same features, but using an external XML config file instead of internal DSL: https://docs.spring.io/spring-boot/docs/2.3.1.RELEASE/maven-plugin/reference/html/#repackage-layers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment