Allow workspace to customize deps while calling load_j2cl_repo_deps
Fixes
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
-_IO_BAZEL_RULES_CLOSURE_VERSION = "master"
-_BAZEL_SKYLIB_VERSION = "0.7.0"
-
def load_j2cl_repo_deps():
- http_archive(
+ _github_repo(
name = "io_bazel_rules_closure",
- strip_prefix = "rules_closure-%s" % _IO_BAZEL_RULES_CLOSURE_VERSION,
- url = "https://github.com/bazelbuild/rules_closure/archive/%s.zip"% _IO_BAZEL_RULES_CLOSURE_VERSION,
+ repo = "bazelbuild/rules_closure",
+ tag = "master",
)
- http_archive(
+ _github_repo(
name = "bazel_skylib",
- strip_prefix = "bazel-skylib-%s" % _BAZEL_SKYLIB_VERSION,
- url = "https://github.com/bazelbuild/bazel-skylib/archive/%s.zip"% _BAZEL_SKYLIB_VERSION,
+ repo = "bazelbuild/bazel-skylib",
+ tag = "0.7.0",
)
+def _github_repo(name, repo, tag):
+ if name in native.existing_rules():
+ return
+
+ _, project_name = repo.split("/")
+ http_archive(
+ name = name,
+ strip_prefix = "%s-%s" % (project_name, tag),
+ url = "https://github.com/%s/archive/%s.zip" % (repo, tag),
+ )
