From d2d303a2f8117009d7906d26225024345b286cfb Mon Sep 17 00:00:00 2001 From: Derek Cormier Date: Wed, 15 Nov 2023 15:35:55 -0800 Subject: [PATCH] Fix bzlmod (#600) (#660) * fix: gazelle is not a devdep It's easy to see because we reference the symbol two lines below here * fix: gazelle must be a regular dep I found this mistake when trying to use bazel-lib in a downstream repo. Co-authored-by: Alex Eagle --- .bcr/patches/go_dev_dep.patch | 33 ++++++++++++++++++++++----------- MODULE.bazel | 20 +++++++++++++++++--- 2 files changed, 39 insertions(+), 14 deletions(-) diff --git a/.bcr/patches/go_dev_dep.patch b/.bcr/patches/go_dev_dep.patch index e20f3a1..99b1bc4 100644 --- a/.bcr/patches/go_dev_dep.patch +++ b/.bcr/patches/go_dev_dep.patch @@ -1,16 +1,27 @@ diff --git a/MODULE.bazel b/MODULE.bazel -index f05c57a..4cb6104 100644 +index 07a6eff..26702ad 100644 --- a/MODULE.bazel +++ b/MODULE.bazel -@@ -28,9 +28,9 @@ register_toolchains( - # To allow /tools to be built from source - # NOTE: when publishing to BCR, we patch this to be dev_dependency, as we publish pre-built binaries - # along with our releases. --bazel_dep(name = "rules_go", version = "0.41.0", repo_name = "io_bazel_rules_go") -+bazel_dep(name = "rules_go", version = "0.41.0", repo_name = "io_bazel_rules_go", dev_dependency = True) - --go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps") -+go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps", dev_dependency = True) +@@ -34,19 +34,19 @@ register_toolchains( + bazel_dep( + name = "gazelle", + version = "0.33.0", +- # In released versions: dev_dependency = True ++ dev_dependency = True + ) + bazel_dep( + name = "rules_go", + version = "0.41.0", + repo_name = "io_bazel_rules_go", +- # In released versions: dev_dependency = True ++ dev_dependency = True + ) + + go_deps = use_extension( + "@gazelle//:extensions.bzl", + "go_deps", +- # In released versions: dev_dependency = True ++ dev_dependency = True + ) go_deps.from_file(go_mod = "//:go.mod") use_repo( - go_deps, diff --git a/MODULE.bazel b/MODULE.bazel index cf3f65b..5e4eabc 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -28,9 +28,24 @@ register_toolchains( # To allow /tools to be built from source # NOTE: when publishing to BCR, we patch this to be dev_dependency, as we publish pre-built binaries # along with our releases. -bazel_dep(name = "rules_go", version = "0.41.0", repo_name = "io_bazel_rules_go") -go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps") +bazel_dep( + name = "gazelle", + version = "0.33.0", + # In released versions: dev_dependency = True +) +bazel_dep( + name = "rules_go", + version = "0.41.0", + repo_name = "io_bazel_rules_go", + # In released versions: dev_dependency = True +) + +go_deps = use_extension( + "@gazelle//:extensions.bzl", + "go_deps", + # In released versions: dev_dependency = True +) go_deps.from_file(go_mod = "//:go.mod") use_repo( go_deps, @@ -42,4 +57,3 @@ use_repo( bazel_dep(name = "bazel_skylib_gazelle_plugin", version = "1.4.1", dev_dependency = True) bazel_dep(name = "buildifier_prebuilt", version = "6.3.3", dev_dependency = True) -bazel_dep(name = "gazelle", version = "0.33.0", dev_dependency = True)