Last active
September 24, 2020 13:36
-
-
Save meteorcloudy/ec9223b1b9216acb0d2861a3b1961011 to your computer and use it in GitHub Desktop.
Example usages of bazel_dep and patch_dep in MODULE.bazel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module( | |
name = "my_awesome_project", | |
version = "0.0.1", | |
author = "Yun Peng", | |
description = "Demo project", | |
compatibility_level = "1", | |
# module_rule_exports = [], | |
) | |
workspace_settings( | |
deps_root = "third_party", | |
registries = [ | |
"https://github.com/bazelbuild/bazel-central-registry.git", | |
"https://github.com/meteorcloudy/my-private-registry.git", | |
], | |
) | |
bazel_dep(name = "com_google_guava", version = "29.0", repo_name = "guava") | |
bazel_dep(name = "com_google_protobuf", version = "3.13.0") | |
bazel_dep(name = "com_github_grpc_grpc", version = "1.27.0") | |
bazel_dep(name = "com_google_absl", version = "20200225.2") | |
bazel_dep(name = "org_junit_junit", version = "4.11", dev_dependency = True) | |
# Override with a local copy | |
patch_dep( | |
module_name = "com_google_protobuf", | |
local_path_override = "../my_own_local_protobuf", | |
) | |
# Override the registry source | |
# Instead of finding this module from the list of registries provided in workspace_setting, | |
# use the specified registry as the source. | |
# Note that the dependency of com_google_absl will not be affected. | |
patch_dep( | |
module_name = "com_google_absl", | |
registry = "https://github.com/meteorcloudy/my-private-registry.git", | |
) | |
# Override with a git repository | |
# If rev is specified, then all modules requiring com_github_grpc_grpc will use this specified version. | |
# If rev is not specified, then this git repo is considered as a single-module Bazel registry, | |
# which serves as the source for this module. | |
patch_dep( | |
module_name = "com_github_grpc_grpc", | |
git = "https://github.com/meteorcloudy/grpc.git", | |
rev = "d179f967be0da96fdcba0b168b439e15c231b035", | |
) | |
# Split unresolvable diamond dependency by allowing multiple versions of the same module. | |
# For example, when bazel_skylib is required for versions [0.7.0, 0.8.0, 1.0.1, 1.0.3]. | |
# Although versions 0.* are not compatible with 1.*, but allowing them to co-exist won't cause any linking conflict. | |
# In this case, the user can specify allow_multiple_versions = True for this module. | |
patch_dep( | |
module_name = "bazel_skylib", | |
# This will be implemented as repo_mapping | |
# For modules requires 1.0.3 (or compatible versions), they will have {"bazel_skylib": "bazel_skylib_1_0_3"} | |
# For modules requires 0.8.0 (or compatible versions), they will have {"bazel_skylib": "bazel_skylib_0_8_0"} | |
allow_multiple_versions = True, | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment