Now that Bazel (http://bazel.io/) has been opensourced, is there an incremental process by which I can gradually migrate (a large repository) from Maven to Bazel?
-
Are you aware that bazel does not support windows? – khmarbaise Mar 30 '15 at 09:16
-
4@khmarbaise I am. Is that important? – Niel de Wet Mar 30 '15 at 14:10
-
1No. I was just curious. But i don't see any smooth path for migration. Just start the bazel build definition and keep (if possible) the maven build in parallel in the same source tree. BTW: They have only partially opensourced bazel. – khmarbaise Mar 30 '15 at 15:52
-
3Windows is supported now. https://docs.bazel.build/versions/master/windows.html – Jin May 24 '18 at 21:12
4 Answers
I work on Bazel. No, as far as we know there is no such process. I wish.
We have been running some migrations from other build systems to Bazel; the evidence isn't conclusive, but it's difficult to even envision how an incremental process would look like. There are some scenarios where we can envision one build system generating configuration files for another (like gyp), but then you still need to switch wholesale.

- 1,319
- 10
- 12
In the two years since Ulf responded, there's been a few efforts to assist with maven to bazel migration. In particular, the Bazel team is creating a tool to assist with this: https://github.com/bazelbuild/migration-tooling
The tool generates expansive WORKSPACE files from a set of pom files or maven coordinates. In the ideal case, you can pass the path to your maven project, and then it will generate a bzl file you can load into the WORKSPACE file.
More commentary on how to manage external dependencies can be found here: https://bazel.build/versions/master/docs/external.html

- 244
- 1
- 11
-
While this may answer the question, [it would be preferable](http://meta.stackoverflow.com/q/8259) to include the essential parts of the answer here, and provide the link for reference. – Peter Jun 30 '17 at 13:19
-
Sept 2019 update: Wix released a tool to automate migration from Maven to Bazel. https://wix.github.io/exodus/index.html – Jin Sep 04 '19 at 18:38
And another update (2018)...
There is a dedicated guide on migrating from Maven build tool to Bazel.
And on a general note, it’s best to have both build tools running in parallel until you have fully migrated your development team, CI system, and any other relevant integrations. You can run Maven and Bazel in the same repository.

- 14,397
- 15
- 77
- 118
-
Regarding a CI/CD system, does Bazel have something similar to the Maven releease plugin? E.g. managing versions and release deployment artifacts? – OneCricketeer Dec 03 '18 at 23:55
September 2019 update
Wix published a tool called Exodus to automatically migrate your Maven project to Bazel.
Additionally, rules_jvm_external has support for managing transitive Maven artifact dependencies.
May 2018 update
Here's another update using Jadep, a BUILD file generator for your Java projects.
There's a tutorial by the author who migrated google-java-format
to Bazel: https://github.com/cgrushko/text/blob/master/migrating-gjf-to-bazel.md

- 12,748
- 3
- 36
- 41