Thursday, March 26, 2009

Jar Manifest Attribute Names

I probably should have known this before, but I discovered today that a "." character is invalid for a jar manifest attribute name. The attribute name is limited to:

{A-Z} | {a-z} | {0-9} | - | _

I tried using an attribute name of "java.version" in my jar manifest and the jar was created by the Maven build without any problem, but when the jar was used as a dependency of another project, then I got a warning about an invalid name.

The maven jar plugin and maybe assembly plugin should probably do some regex validation while creating the jar to at least give a warning. Otherwise maven will happily create a jar with invalid manifest and you may not discover this error until it starts causing some problems in other projects. I created a Jira Issue about this.

No comments: