I need to add the following headers to the MANIFEST.MF file using Gradle and Spring Boot:
Is there a way to configure the Gradle build process to read these values from settings.gradle and build.gradle and write them to the MANIFEST.MF file?
Writing them to the manifest file is described here: add manifest file to jar with gradle
To populate these values from settings.gradle
and gradle.properties
, consider the following:
build.gradle
plugins {
id "idea"
id "java"
}
jar {
manifest {
attributes 'Specification-Title': gradle.ext.jonesVar
attributes 'Specification-Version': bibibi
}
}
settings.gradle
gradle.ext.jonesVar = "jones"
gradle.properties
bibibi=3
The result from ./gradlew clean build
gives build/libs/tmp.jar
containing this manifest:
MANIFEST.MF
Manifest-Version: 1.0
Specification-Title: jones
Specification-Version: 3
If you need to do this for the bootJar
, use bootJar {
instead of jar {
in your build.gradle
.