cqengine icon indicating copy to clipboard operation
cqengine copied to clipboard

Provide shaded version with relocated dependencies

Open fmannhardt opened this issue 8 years ago • 6 comments

Currently, the "-all.jar" includes all dependencies, but keeps the original package names of all dependencies. In some cases this might lead to problems, for example, when a project depends on the "-all.jar", but also depends on one of the included libraries in a different version.

Could you use the "relocations" configuration in the maven shade plug-in, to rename the packages of all dependencies to something like "com.googlecode.cqengine.org.sqlite...". This would help preventing clashes when using the "-all.jar" in situations where it is not easy to control the versions of all dependencies.

fmannhardt avatar Aug 18 '16 10:08 fmannhardt

Hi Felix,

This is already the case. The shaded "-all.jar" does relocate the package names of dependencies to a new package com.googlecode.cqengine.lib.*.

But there is indeed one exception: org.sqlite which is provided by the sqlite-jdbc project.

I found that the SQLite jar does not behave well when relocated. I was not able to solve it, and it's why this remains an exception to the rule. The sqlite-jdbc jar does not seem to be compatible with shading/relocating its code.

I think to resolve this we'd need to open a bug/feature request in the upstream project. The problem isn't related to CQEngine specifically - I think it will affect any downstream project which tries to shade that jar.

Which means it should be straightforward to write a standalone test case which demonstrates the issue, which would be helpful to the upstream developers.

I'd like to see this particular issue fixed, but it's a low priority for me because the current setup works okay for me. However if you have time to chase this upstream(?) I'd be happy to help or advise. When it's fixed upstream, it would then be trivial to integrate it into CQEngine.

npgall avatar Aug 18 '16 12:08 npgall

Thanks for the info. I will file a bug with sqlite

fmannhardt avatar Aug 19 '16 11:08 fmannhardt

I created an issue in the sqlite-jdbc package: issue 145

fmannhardt avatar Sep 05 '16 09:09 fmannhardt

Nice work Felix! When it's fixed upstream, I can update CQEngine to use the fixed version.

npgall avatar Sep 06 '16 22:09 npgall

I tried to use the "-all.jar" but I found that it is not a drop-in replacement for the regular cqengine jar. This is because besides for relocating dependencies, it also relocates all the cqengine classes. This means that I cannot easily switch between the "-all" and the regular jar file. In order to ensure code that uses is more maintainable it should only relocate dependencies and not its own classes.

shollander avatar May 10 '17 16:05 shollander

@shollander actually CQEngine's own classes are not supposed to be relocated in the shaded jar. I created issue #144 to fix that problem.

npgall avatar May 30 '17 00:05 npgall