Skip to content

Instantly share code, notes, and snippets.

@jkuipers
Created June 23, 2020 21:18
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jkuipers/0ec336cb97ae356f60861b11145557d9 to your computer and use it in GitHub Desktop.
Save jkuipers/0ec336cb97ae356f60861b11145557d9 to your computer and use it in GitHub Desktop.
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

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

@jkuipers
Copy link
Author

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