Skip to content

Commit

Permalink
Writing resolved Go modules as K:V JSON for external bookkeeping
Browse files Browse the repository at this point in the history
  • Loading branch information
Buzz-Lightyear authored and Srinivas Muthu committed Aug 29, 2024
1 parent 1a98d35 commit 7916a0f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/bzlmod/go_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,7 @@ def _go_deps_impl(module_ctx):
),
)

resolved_go_modules = {}
for path, module in module_resolutions.items():
if hasattr(module, "module_name"):
# Do not create a go_repository for a Go module provided by a bazel_dep.
Expand Down Expand Up @@ -643,8 +644,10 @@ def _go_deps_impl(module_ctx):

go_repository_args.update(repo_args)

resolved_go_modules[go_repository_args["importpath"]] = go_repository_args["version"]
go_repository(**go_repository_args)

module_ctx.file("./resolved_go_modules.json", content=json.encode_indent(resolved_go_modules))
# Create a synthetic WORKSPACE file that lists all Go repositories created
# above and contains all the information required by Gazelle's -repo_config
# to generate BUILD files for external Go modules. This skips the need to
Expand Down

0 comments on commit 7916a0f

Please sign in to comment.