Stick it in the Manifest

Created: 2013/02/18 22:42:03+0000 Revised: 2013/02/20 20:53:24+0000 Revisions:  2 1

Recently at work I came across a Great Idea or at least a very good practice for Java developers. I was gathering information on the use of open source software at work, which no one had kept track of before. This meant that the libraries, versions and license information was unknown. Sometimes this was simple enough. The JAR files would start with the library name and had the version appended to them. The licenses could be looked up online. Sometimes it wasn't straight forward. The version wasn't appended or in the case of the Servlet API is a standard and has multiple implementations.

So I opened up the JAR file to try and find the information I needed and there in the manifest file was everything I needed. Manifest entries detailing the library, version, license, vendor and everything else I needed. It is already a widespread practice, most of the libraries I looked at had this information but not all of them. This practice should be universal.

The version information can entered using Java's package versioning specification which allows the version information to be retrieved programmatically. If you are using Maven, the Maven JAR plugin can put these values into the manifest. There is an Ant task that can be used to create a manifest file. It was pointed out to me by a gentleman at work that JD-GUI is a much better way to read the manifest file than using an archiver to peek inside.