How to Migrate from Maven to Bazel

37 views
Skip to first unread message

amansi...@gmail.com

unread,
Jul 9, 2020, 2:22:32 PM7/9/20
to bazel-discuss
Hi Everyone,

We have a monorepo with ~40 modules and 10k java files.
We have been using maven for build but it has become incredibly slow and we are forced to think of alternatives. We evaluated different build tools and decided to go ahead with Bazel due to its adoption and functionalities. But I have few questions:

How to migrate the existing code. I can think of 2 ways: 
1. Do it manually. Start from the lower level modules and start the migration each dependency for each of the modules. For small sized modules, this might work, but I can see us getting stuck in the bigger modules we have which have more than 200 maven deps. 
2. Use Exodus. Exodus is an amazing tool and does magic for migration. But due to size of our module, we are facing some issues in using it. Exodus team is super helpful and are working on a optimisation which can help us. I will need to check if the optimisation fixes the issue for us. 
3. Is there any other option apart from these 2? I searched a lot but couldn't find anything which can help us in the migration. We are ok with module level build files as well.


TIA!

Daniel Halperin

unread,
Jul 9, 2020, 7:58:25 PM7/9/20
to amansi...@gmail.com, bazel-discuss
For our project we did 1. (https://gitub.com/batfish/batfish)

We started with 1 build file per Maven module, and a single java_library and junit_tests per module. Over time we've split some of the module up, but honestly it's still too monolithic. Breaking it up isn't blocking anything though..

A few hundred maven deps -- not that big a deal with rules_jvm_external. IIRC we ran a version of mvn dependency:list and post-processed the output to generate the library_deps.bzl file. IIRC, getting the runtime_deps right was a little tricky, but ultimately easy. I think that unused_deps tool has made this overall process much easier in the interim.

I dunno, I think I spent less than half a day on the conversion.

Dan

--
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/64d9da7b-c0c0-4ee4-833a-a845a6eb5aeeo%40googlegroups.com.

Steven Parkes

unread,
Jul 9, 2020, 8:25:34 PM7/9/20
to Daniel Halperin, amansi...@gmail.com, bazel-discuss
We added (some) bazel build support to spark. It's not complete: it only builds the parts of spark we use and there are cases where the spark test infra, based on maven and including some integration testing, is not compatible with bazel ... at least not without significant changes, particularly given we need to support maven and bazel builds in parallel.

It's a moderately big code base (~5K java/scala files). I did it manually: it started out as an experiment, not being sure it could be completed. It took a few days, in particular going through the tests which include fairly complicated setups and when they fail, fail in complicated ways. But I thought (and still tend to think) it might be easier to do the conversion manually than spending time trying to debug the result of an automatic conversion.

Aman Singh

unread,
Jul 10, 2020, 12:53:29 AM7/10/20
to Daniel Halperin, bazel-discuss
Thanks for sharing the strategy Daniel. How much improvement in build time were you able to get by migrating the project to one build file per module?
Reply all
Reply to author
Forward
0 new messages