lz4 / lz4-java

LZ4 compression for Java
Apache License 2.0
1.11k stars 252 forks source link

Made L4Z Java's JAR a valid OSGi bundle. #39

Closed magnet closed 10 years ago

magnet commented 10 years ago

This pull request fixes issue #30.

This lz4-java build now generates a valid OSGi bundle. The same JAR (same name, same everything) will keep the same behavior from non-OSGi Java environments. I tested quickly from an OSGi container on Linux/amd64 with a manual test (instantiated the 3 implementations) and using DataStax's Java driver for Cassandra.

Please note that in OSGi, packages are the "code modules" that are getting imported and exported, and are thus versioned. The best practice is to version them separately, depending on the semantic changes they go through between releases. A package within a given bundle (the deployment unit, i.e the JAR) could keep the same version while the bundle version changes. A common idiom is to have a simple text file named packageinfo in each package we mean to export that contain its version. This file is then picked-up by bnd, the bundle tool making, to export the proper version for each package. Since I didn't want to change that significantly your development habits by creating those files that you might forget to update when you make incompatible changes, I take the Ivy revision value as the exported package version. This means that all packages have the same version (same as the bundle), and also that in the case of revisions having the -SNAPSHOT suffix I have to strip it out. Unfortunately I found nothing shorter/better than doing this using ant's scripting abilities (with JavaScript).

Here are the main changes:

Thanks for looking into it (and if you accept the pull-req, possibly backporting the changes if the next release won't happen soon), and for making LZ4 available for Java :).