13

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?

Niel de Wet
  • 7,806
  • 9
  • 63
  • 100

4 Answers4

12

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.

Ulf Adams
  • 1,319
  • 10
  • 12
3

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

petros-eskinder
  • 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
3

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.

https://docs.bazel.build/versions/master/migrate-maven.html

Johnny
  • 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
3

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

Jin
  • 12,748
  • 3
  • 36
  • 41