Windows EXE files (and many other file types) contain useful metadata like the file version, copyrights, etc. Is it possible to direct Gradle to insert such info to a JAR file it is building? (and how can you read it via bash?)
This resource information is embedded in Windows PE formatted files (exe, dll, sys, etc). It is not something generic that Windows Explorer can extract and display from any file. The jar format is a zip file and does not contain such resource information.
To be fair, it’s not just Windows-only files… .mp3, .jpg and other media files also have attached metadata, readable on any platform.
I’ll expand the scope of my question: is there any way to mark a JAR file with a version number or other identifier, such that it is possible to identify and distinguish from another file with the same name?
Thank you.
Yes, those file formats also contain format-specific meta-data that Explorer and other apps know how to read.
You can store meta-data in a jar file’s default manifest, META-INF/MANIFEST.MF
.
In Gradle you can manipulate the manifest content by configuring the jar
task. This meta-data is not something native to the file format, just another file in the zip.
OK thanks for the help. I’m aware of the manifest.mf
file and how to add attributes to it.