jglick / sezpoz

SezPoz: lightweight, annotation-based service loader
29 stars 11 forks source link

Clean way to merge META-INF/annotations/* entries from multiple JARs #2

Open jglick opened 11 years ago

jglick commented 11 years ago

Originally filed in JIRA.

Combining several JARs into one is pretty straightforward using Maven's assembly feature, except that when the same file exists in multiple JARs, it will be repeatedly overwritten when they are unpacked into a common directory structure. Unfortunately, this means that SezPoz annotations in META-INF/annotations across multiple JARs overwrite one another.

CombineAnnotations can be used to work around this, though it is awkward. Could also use something other than the assembly plugin to create a master JAR; anything that does not rely on combining ZIP entries would work.

But for cases where merging ZIP entries is necessary, an official solution is needed. One possibility is to make an implementation of ContainerDescriptorHandler which would understand how to merge these files. Such a plugin would I presume somehow be added as a dependency to the assembly plugin and then used as part of your assembly descriptor. Resource transformers are also relevant.

Another option would be to change the SezPoz index format to work with simple concatenation, which is more likely to be supported out of the box by assembly tools: #6. (The old index files would need to still be accepted for binary compatibility, of course.)

ctrueden commented 9 years ago

Just wanted to add an up-to-date link to the CombineAnnotations logic here. (The URL in the description is now defunct, unfortunately.)

jglick commented 9 years ago

Thanks!