I have multiple java projects. these projects are creating jar,war and ear files using gradle. In each project I have used manifest file to maintain the meta data like version,date-time... Fro this I have included the manifest file creation logic in every build.gradle file.
manifest {
attributes(
'Bundle-Vendor' : "$BUNDLE_VENDOR",
'Build-Time': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"))
}
But in Gradle there is a feature call sharedManifest. I have defined the bellow two tasks in main project build.gradle script. But in the every jar and war file have the default MANIFEST.MF file created by Gradle.
ext.sharedManifest = manifest {
attributes(
'Bundle-Vendor' : "$BUNDLE_VENDOR",
'Build-Time': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
)
}
task fooJar(type: Jar) {
manifest = project.manifest {
from sharedManifest
}
}
task fooWar(type: War) {
manifest = project.manifest {
from sharedManifest
}
}
jar.manifest.writeTo("/MANIFEST.MF") war.manifest.writeTo("/MANIFEST.MF")
please can some one give the suggestion how to do this.