From daf5b04744b88fbd23878396dc047b8f2e33c296 Mon Sep 17 00:00:00 2001 From: Yannic Date: Mon, 16 Sep 2019 10:57:16 +0200 Subject: [PATCH] Deprecate closure_repositories in favor of rules_closure_{dependencies,toolchains} (#423) This PR adds macros to closure/repositories.bzl to make rules_closure more compliant with Bazel's Style Guide for Rules. Working towards #421 --- WORKSPACE | 8 +++----- closure/defs.bzl | 3 +-- closure/repositories.bzl | 25 ++++++++++++++++++++++++- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index de4b09bd41..9024f4dc3a 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -2,13 +2,11 @@ workspace(name = "io_bazel_rules_closure") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("//closure/private:java_import_external.bzl", "java_import_external") -load("//closure:repositories.bzl", "closure_repositories") -closure_repositories() +load("@io_bazel_rules_closure//closure:repositories.bzl", "rules_closure_dependencies", "rules_closure_toolchains") +rules_closure_dependencies() +rules_closure_toolchains() -load("//closure:toolchains.bzl", "closure_register_toolchains") - -closure_register_toolchains() java_import_external( name = "com_google_guava_testlib", diff --git a/closure/defs.bzl b/closure/defs.bzl index 45054cd6d7..10e364b5fa 100644 --- a/closure/defs.bzl +++ b/closure/defs.bzl @@ -52,7 +52,6 @@ closure_template_library = _closure_template_library closure_js_test = _closure_js_test phantomjs_test = _phantomjs_test filegroup_external = _filegroup_external -closure_repositories = _closure_repositories -closure_register_toolchains = _closure_register_toolchains +closure_repositories = _closure_repositories # TODO(yannic): Remove on 2019-11-01. web_library = _web_library web_library_external = _web_library_external diff --git a/closure/repositories.bzl b/closure/repositories.bzl index 49b95dac0f..0979e6a100 100644 --- a/closure/repositories.bzl +++ b/closure/repositories.bzl @@ -18,7 +18,30 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file" load("//closure/private:java_import_external.bzl", "java_import_external") load("//closure/private:platform_http_file.bzl", "platform_http_file") -def closure_repositories( +_ERROR_CLOSURE_REPOSITORIES_IS_DEPRECATED = """ +closure_repositories() is deprecated. + +Please add the following to your workspace instead: + + load("@io_bazel_rules_closure//closure:repositories.bzl", "rules_closure_dependencies", "rules_closure_toolchains") + rules_closure_dependencies() + rules_closure_toolchains() +""".strip() + +def closure_repositories(**kargs): + """Legacy macro to import dependencies for Closure Rules.""" + + print(_ERROR_CLOSURE_REPOSITORIES_IS_DEPRECATED) + rules_closure_dependencies(**kargs) + +def rules_closure_toolchains(): + """An utility method to load all Closure toolchains. + + It doesn't do anything at the moment. + """ + pass + +def rules_closure_dependencies( omit_aopalliance = False, omit_args4j = False, omit_bazel_skylib = False,