Packaging and distributing taglibs in a JAR

This is more of a “note to self” than a “how to”.

If you’re trying to distribute tag files in a JAR, you need to put them under /META-INF/tags. You then need to create a TLD file that you also put under /META-INF/tags. If you have tags or functions that you created in Java, and want to distribute them alongside the tag files, you need to reference them in the TLD and package them in the same JAR (goes without saying).

If you want to do the same thing in maven, the location for the tag files and the tld file is different; you need to put them in src/main/resources/META-INF/tags. Then you can run mvn package and maven will create a JAR with your tags.
Read the rest of this entry »