Saturday, July 30, 2011

Contributing back to the open-source. A JSP taglib to read maven generated version values from MANIFEST.MF

Update 2011-08-09: Turns out it is not possible to externalized it into a separate taglib project.  I suspect it is actually reading the MANIFEST.MF from the taglib jar itself rather than the MANIFEST.MF file of the referencing project. The project from bitbucket have been deleted.
------
I have been searching the web to find a taglib which read the version information from the MANIFEST.MF file. Since this is very commonly used, I am surprise I was not able to readily find such a JSP taglib available!

This got to be a common problem since I found plenty of references on how to read version information from the MANIFEST.MF file. For example:

http://stackoverflow.com/questions/1906266/maven-2-how-to-package-current-project-version-in-a-war-file
http://www.flexthinker.com/2010/04/avoid-users-cache-when-deploying-new-versions-of-flex-app/
...

Instead of keep repeating myself, I decide to just quickly put one together and share it through the web. I have also threw together some quick instruction on how to use it on the bitbucket wiki https://bitbucket.org/lsiu/qds-commons-web/wiki/Home.

Here is the taglib in action:


The "1.0 (5956254adaaa+)" is just reading from the MANIFEST.MF file which in turn is populated automatically during the maven build process by the maven-war-plugin.


BTW, if anyone know of such a tag library, please give me a shout.  I will be happy to "unpollute" the web with yet another "roll-my-own-code" doing the exact same thing.