rules_gwt
rules_gwt copied to clipboard
java_import_external
@ekuefler, you may recall https://github.com/bazelbuild/bazel/issues/1952 where we had a discussion about best practices for defining Maven dependencies.
With your approval, I would like to volunteer my time to migrate this project to what seems to be the emerging consensus. That would entail modifying gwt/gwt.bzl to use java_import_external.
List of Converted Projects
- Nomulus: https://github.com/google/nomulus/blob/master/java/google/registry/repositories.bzl
- Closure Rules: https://github.com/bazelbuild/rules_closure/blob/master/closure/repositories.bzl
- Web Testing Rules: https://github.com/bazelbuild/rules_webtesting/blob/master/web/repositories.bzl
- TensorFlow: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/workspace.bzl#L422
Benefits of Migration
-
Faster downloads, redundant URLs, connection retries, exponential backoff, connection reset recovery, fast failover, auto-avoidance of low-bandwidth mirrors, captive portal avoidance, and compliance with policies of certain great firewalls. See: https://github.com/bazelbuild/bazel/commit/ed7ced0018dc5c5ebd6fc8afc7158037ac1df00d
-
Shorter names. You can say
deps = ["@com_google_guava"]
instead ofdeps = ["@com_google_guava//jar"]
. -
Dependency relationships are encoded into repositories. If you want
//external:gwt_jetty
you currently need to depend on//external:gwt_jetty
AND//external:gwt_jetty-io
AND//external:gwt_jetty-util
because maven_jar didn't let you specify that jetty depended on those jars. With java_import_external, if you want jetty, you just depend on jetty. -
Ability to set
testonly = 1
which maven_jar doesn't do. -
Ability to set
licenses = ["notice"]
, etc. which maven_jar doesn't do. -
Ability to define annotation processors. See Dagger example here.
If you find the technical merits of these developments compelling, let me know, and I'll move forward.
Side note: I have another cool repository rule I've developed called filegroup_external (source) which you may also find interesting. I'd love to hear your thoughts.
Go for it! Glad to here there's growing consensus here and the new rules look pretty slick. I'm not overly happy with the current state of the GWT dependencies, so feel free to modify them however you think would make the most sense (and update instructions in the README accordingly).
Thanks for all your work figuring out best practices here.