My goal is to produce an artifact of my Spring Boot application that I can use as a dependency and [edit] that is a fat jar, that is, it contains all the dependencies of my application [edit].
I use gradle as a build tool with the following plugins:
plugins {
id 'java'
id 'org.springframework.boot' version '2.7.4'
id 'io.spring.dependency-management' version '1.0.14.RELEASE'
id 'org.jetbrains.gradle.plugin.idea-ext' version '1.1.6'
}
Now, the Spring Boot documentation states at https://docs.spring.io/spring-boot/docs/current/reference/html/howto.html#howto.build.use-a-spring-boot-application-as-dependency that
'Spring Boot’s Maven and Gradle plugins must be configured to produce a separate artifact that is suitable for use as a dependency [...] To produce the two artifacts, one that can be used as a dependency and one that is executable, a classifier must be specified. This classifier is applied to the name of the executable archive, leaving the default archive for use as a dependency.'
This is followed by a description on how to do this with the build tool maven, but there is no mentioning of how to do this in gradle.
Any help of how to set this up with gradle is much appreciated.
CodePudding user response:
When building with Gradle, an artifact with a plain
classifier is built by default. This artifact is a standard, plain jar file that is suitable for use as a dependency.