relocating classes in an imported jar

428 views
Skip to first unread message

Warren Turkal

unread,
Nov 6, 2015, 1:11:50 AM11/6/15
to bazel-discuss
Hey everyone,

I am trying to deal with a project that uses two versions of a java maven package in different parts of the code. One of the jars is "shaded" under a different namespace using the following maven plugin:
https://maven.apache.org/plugins/maven-shade-plugin/

Here is the specific link with an example of relocating classes within a jar:

I would like to be able to import a jar (e.g. kafka-client) and move it from it's original namespace (e.g. kafka.*) to some other namespace (e.g. new_pkg_name.kafka.*). Is it possible to do such a thing in bazel?

Thanks,
wt

Han-Wen Nienhuys

unread,
Nov 6, 2015, 3:05:36 AM11/6/15
to Warren Turkal, bazel-discuss
the link you describe says this works by moving around files in the
.jar and rewriting the byte code. If you have a command line utility
that does this, you could invoke it from a genrule.
> --
> You received this message because you are subscribed to the Google Groups
> "bazel-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to bazel-discus...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/bazel-discuss/dadb54b8-37a6-4136-90b1-071be705d083%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Han-Wen Nienhuys
Google Munich
han...@google.com

Warren Turkal

unread,
Nov 6, 2015, 2:47:34 PM11/6/15
to Han-Wen Nienhuys, bazel-discuss
Jar Jar Links to the rescue:
https://code.google.com/p/jarjar/

I will probably try to write up some sky lark rules around this functionality. I'll prototype with jar jar links. I see that asm (the magic lib that jar jar uses) is already included in the third party libs in bazel. Maybe I'll see if I can integrate this functionality in a better way.

wt
Reply all
Reply to author
Forward
0 new messages