bazeltools / bazel_jar_jar

JarJar rules for bazel (rename packages and classes in existing jars)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

New user guide to jar_jar and bazel-deps

sid374 opened this issue · comments

Preface: I'm new to bazel, bazel-deps and jar_jar. I've tried reading the available documentation but haven't found satisfactory answers suitable for a new user.

Problem:
We use bazel-deps to download and use a bunch of 3rd party dependencies. Two of these libraries (azure-storage and cassandra-driver) have conflicting dependencies on the version of guava that they require (20 and 19 respectively). I'm trying to use bazel_jar_jar to shade the azure-storage library so that I can have 2 different versions of guava coexist.

Questions:

  1. Is there a way to make bazel_jar_jar play nice with bazel-deps? Bazel deps seems to generate it's own BUILD.bazel files for every dependency specified. There's a warning saying that we shouldn't edit these files manually, which I would have to do to use jar_jar. I see a bunch of options in the documentation but it's not clear if any of them can help setting up bazel_jar_jar rules
  2. Could someone please give point me to a beginner friendly guide/documentation which I can follow to get some more insight

bazel-deps wants to normalize all version jars down to 1 single jar. There isn't a mechanism to nave separate ones.

What I would do if I were trying to solve this would be to have two configuration files:

  1. your main/default versions.
  2. the minimal set you need for the exceptional cases.

then generate two separate third party directories, and then you could use jar_jar to shade one of them.

We use shading in a few cases at Stripe, but we usually manage this by manually adding those jars via http_jar or similar and constructing by hand the target we need. It's not fun, but the goal of the monorepo is a single version of all jars, so we work more to get there than to solve workarounds for mixing versions.

I hope this is helpful.

Good luck.

Thanks for the insight! My current approach was to do it by hand, but will give what you suggested a shot as well.

There doesn't really seem to be a clean way around this, since the issue is inherently messy.