-->

Is there a migration path from Maven to Bazel?

2019-06-15 08:14发布

问题:

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?

回答1:

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



回答2:

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.



回答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



回答4:

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