diff --git a/MODULE.bazel b/MODULE.bazel
index 59ac8ae86..e0146928d 100644
--- a/MODULE.bazel
+++ b/MODULE.bazel
@@ -5,7 +5,7 @@ module(
# MARK: - Runtime Dependencies
-bazel_dep(name = "cgrindel_bazel_starlib", version = "0.16.2")
+bazel_dep(name = "cgrindel_bazel_starlib", version = "0.17.0")
bazel_dep(name = "bazel_skylib", version = "1.4.2")
bazel_dep(
name = "rules_go",
@@ -29,7 +29,7 @@ bazel_dep(
)
bazel_dep(
name = "gazelle",
- version = "0.31.1",
+ version = "0.32.0",
repo_name = "bazel_gazelle",
)
diff --git a/README.md b/README.md
index 67ab6c3ab..e925f6001 100644
--- a/README.md
+++ b/README.md
@@ -19,7 +19,7 @@ development inside a Bazel workspace.
* [Linux](#linux)
* [Quickstart](#quickstart)
* [1\. Enable bzlmod](#1-enable-bzlmod)
- * [2\. Configure your workspace to use rules\_swift\_package\_manager\.](#2-configure-your-workspace-to-use-rules_swift_package_manager)
+ * [2\. Configure your workspace to use rules\_swift\_package\_manager \.](https://github.com/cgrindel/rules_swift_package_manager)
* [Bzlmod: Configure your MODULE\.bazel](#bzlmod-configure-your-modulebazel)
* [Legacy: Add declarations to your WORKSPACE file](#legacy-add-declarations-to-your-workspace-file)
* [3\. Create a minimal Package\.swift file\.](#3-create-a-minimal-packageswift-file)
@@ -29,8 +29,8 @@ development inside a Bazel workspace.
* [6\. Create or update Bazel build files for your project\.](#6-create-or-update-bazel-build-files-for-your-project)
* [7\. Build and test your project\.](#7-build-and-test-your-project)
* [8\. Check in some generated files\.](#8-check-in-some-generated-files)
- * [Bzlmod: Check\-in Package\.resolved, swift\_deps\_index\.json, and MODULE\.bazel\.](#bzlmod-check-in-packageresolved-swift_deps_indexjson-and-modulebazel)
- * [Legacy: Check\-in Package\.resolved, swift\_deps\_index\.json, and swift\_deps\.bzl\.](#legacy-check-in-packageresolved-swift_deps_indexjson-and-swift_depsbzl)
+ * [Bzlmod: Check\-in Package\.resolved , swift\_deps\_index\.json , and MODULE\.bazel \.](#bzlmod-check-in-packageresolved-swift_deps_indexjson-and-modulebazel)
+ * [Legacy: Check\-in Package\.resolved , swift\_deps\_index\.json , and swift\_deps\.bzl \.](#legacy-check-in-packageresolved-swift_deps_indexjson-and-swift_depsbzl)
* [9\. Start coding](#9-start-coding)
* [Tips and Tricks](#tips-and-tricks)
* [Future Work](#future-work)
diff --git a/WORKSPACE b/WORKSPACE
index 082a44012..c0c470cdf 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -1,108 +1 @@
-workspace(name = "rules_swift_package_manager")
-
-load("//:deps.bzl", "swift_bazel_dependencies")
-
-swift_bazel_dependencies()
-
-# MARK: - Starlark
-
-load("@cgrindel_bazel_starlib//:deps.bzl", "bazel_starlib_dependencies")
-
-bazel_starlib_dependencies()
-
-load("@buildifier_prebuilt//:deps.bzl", "buildifier_prebuilt_deps")
-
-buildifier_prebuilt_deps()
-
-load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
-
-bazel_skylib_workspace()
-
-load("@buildifier_prebuilt//:defs.bzl", "buildifier_prebuilt_register_toolchains")
-
-buildifier_prebuilt_register_toolchains()
-
-# MARK: - Golang
-
-load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
-load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
-
-# gazelle:repo bazel_gazelle
-
-load("//:go_deps.bzl", "swift_bazel_go_dependencies")
-
-# Workaround for missing strict deps error as described here:
-# https://github.com/bazelbuild/bazel-gazelle/issues/1217#issuecomment-1152236735
-# gazelle:repository go_repository name=in_gopkg_alecthomas_kingpin_v2 importpath=gopkg.in/alecthomas/kingpin.v2
-
-# gazelle:repository_macro go_deps.bzl%swift_bazel_go_dependencies
-swift_bazel_go_dependencies()
-
-# MARK: - Skylib Gazelle Extension
-
-load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
-
-http_archive(
- name = "bazel_skylib_gazelle_plugin",
- sha256 = "3327005dbc9e49cc39602fb46572525984f7119a9c6ffe5ed69fbe23db7c1560",
- urls = [
- "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.4.2/bazel-skylib-gazelle-plugin-1.4.2.tar.gz",
- "https://github.com/bazelbuild/bazel-skylib/releases/download/1.4.2/bazel-skylib-gazelle-plugin-1.4.2.tar.gz",
- ],
-)
-
-load("@bazel_skylib_gazelle_plugin//:workspace.bzl", "bazel_skylib_gazelle_plugin_workspace")
-
-bazel_skylib_gazelle_plugin_workspace()
-
-go_rules_dependencies()
-
-go_register_toolchains(version = "1.19.5")
-
-gazelle_dependencies()
-
-# MARK: - Bazel Integration Test
-
-http_archive(
- name = "rules_bazel_integration_test",
- sha256 = "c8ce8080e55857526da8d8bae2c41074177b869b398d2ec22c6be7e8d22614a3",
- urls = [
- "https://github.com/bazel-contrib/rules_bazel_integration_test/releases/download/v0.15.1/rules_bazel_integration_test.v0.15.1.tar.gz",
- ],
-)
-
-load("@rules_bazel_integration_test//bazel_integration_test:deps.bzl", "bazel_integration_test_rules_dependencies")
-
-bazel_integration_test_rules_dependencies()
-
-load("@rules_bazel_integration_test//bazel_integration_test:defs.bzl", "bazel_binaries")
-
-bazel_binaries(versions = ["//:.bazelversion"])
-
-# Go Deps for bazel-starlib
-
-load("@cgrindel_bazel_starlib//:go_deps.bzl", "bazel_starlib_go_dependencies")
-
-bazel_starlib_go_dependencies()
-
-# MARK: - Swift Toolchain
-
-http_archive(
- name = "build_bazel_rules_swift",
- sha256 = "3a595a64afdcaf65b74b794661556318041466d727e175fa8ce20bdf1bb84ba0",
- url = "https://github.com/bazelbuild/rules_swift/releases/download/1.10.0/rules_swift.1.10.0.tar.gz",
-)
-
-load(
- "@build_bazel_rules_swift//swift:repositories.bzl",
- "swift_rules_dependencies",
-)
-
-swift_rules_dependencies()
-
-load(
- "@build_bazel_rules_swift//swift:extras.bzl",
- "swift_rules_extra_dependencies",
-)
-
-swift_rules_extra_dependencies()
+# Intentionally blank: use bzlmod
diff --git a/bzlmod/workspace/MODULE.bazel b/bzlmod/workspace/MODULE.bazel
index ce72aec21..0cb7519f7 100644
--- a/bzlmod/workspace/MODULE.bazel
+++ b/bzlmod/workspace/MODULE.bazel
@@ -7,7 +7,7 @@ local_path_override(
path = "../..",
)
-bazel_dep(name = "cgrindel_bazel_starlib", version = "0.16.2")
+bazel_dep(name = "cgrindel_bazel_starlib", version = "0.17.0")
bazel_dep(name = "bazel_skylib", version = "1.4.2")
bazel_dep(
name = "rules_swift",
diff --git a/deps.bzl b/deps.bzl
index ff62c8036..1f10ebb11 100644
--- a/deps.bzl
+++ b/deps.bzl
@@ -39,8 +39,8 @@ def swift_bazel_dependencies():
maybe(
http_archive,
name = "cgrindel_bazel_starlib",
- sha256 = "48efed39e8a3c5395d4b7b58a40978563cf0e22fab7e9d8e93989232cc6d9407",
+ sha256 = "a8d25340956b429b56302d3fd702bb3df8b3a67db248dd32b3084891ad497964",
urls = [
- "https://github.com/cgrindel/bazel-starlib/releases/download/v0.16.2/bazel-starlib.v0.16.2.tar.gz",
+ "https://github.com/cgrindel/bazel-starlib/releases/download/v0.17.0/bazel-starlib.v0.17.0.tar.gz",
],
)
diff --git a/docs/faq.md b/docs/faq.md
index 80f28ce9a..1953a9174 100644
--- a/docs/faq.md
+++ b/docs/faq.md
@@ -7,10 +7,10 @@
* [Why split the implementation between Go and Starlark?](#why-split-the-implementation-between-go-and-starlark)
* [How does the Gazelle plugin for Go handle this?](#how-does-the-gazelle-plugin-for-go-handle-this)
* [Is the same build file generation logic used for the Go/Gazelle and Starlark implementations?](#is-the-same-build-file-generation-logic-used-for-the-gogazelle-and-starlark-implementations)
-* [Does this replace rules\_spm?](#does-this-replace-rules_spm)
-* [Can I migrate from rules\_spm to rules\_swift\_package\_manager?](#can-i-migrate-from-rules_spm-to-rules_swift_package_manager)
+* [Does this replace rules\_spm ?](https://github.com/cgrindel/rules_spm/)
+* [Can I migrate from rules\_spm to rules\_swift\_package\_manager ?](https://github.com/cgrindel/rules_spm/)
* [Can I just manage my external Swift packages and not generate Bazel build files for my project?](#can-i-just-manage-my-external-swift-packages-and-not-generate-bazel-build-files-for-my-project)
-* [After running //:swift\_update\_pkgs, I see a \.build directory\. What is it? Do I need it?](#after-running-swift_update_pkgs-i-see-a-build-directory-what-is-it-do-i-need-it)
+* [After running //:swift\_update\_pkgs , I see a \.build directory\. What is it? Do I need it?](#after-running-swift_update_pkgs-i-see-a-build-directory-what-is-it-do-i-need-it)
* [Does the Gazelle plugin run Swift package manager with every execution?](#does-the-gazelle-plugin-run-swift-package-manager-with-every-execution)
* [Can I store the Swift dependency files in a sub\-package (i\.e\., not in the root of the workspace)?](#can-i-store-the-swift-dependency-files-in-a-sub-package-ie-not-in-the-root-of-the-workspace)
diff --git a/examples/firebase_example/MODULE.bazel b/examples/firebase_example/MODULE.bazel
index d8c48a1db..af438c7c3 100644
--- a/examples/firebase_example/MODULE.bazel
+++ b/examples/firebase_example/MODULE.bazel
@@ -7,7 +7,7 @@ local_path_override(
path = "../..",
)
-bazel_dep(name = "cgrindel_bazel_starlib", version = "0.16.2")
+bazel_dep(name = "cgrindel_bazel_starlib", version = "0.17.0")
bazel_dep(name = "bazel_skylib", version = "1.4.2")
bazel_dep(
name = "rules_swift",
diff --git a/examples/grpc_example/MODULE.bazel b/examples/grpc_example/MODULE.bazel
index 88ac4cc6d..de137d877 100644
--- a/examples/grpc_example/MODULE.bazel
+++ b/examples/grpc_example/MODULE.bazel
@@ -7,7 +7,7 @@ local_path_override(
path = "../..",
)
-bazel_dep(name = "cgrindel_bazel_starlib", version = "0.16.2")
+bazel_dep(name = "cgrindel_bazel_starlib", version = "0.17.0")
bazel_dep(name = "bazel_skylib", version = "1.4.2")
bazel_dep(
name = "rules_swift",
diff --git a/examples/http_archive_ext_deps/MODULE.bazel b/examples/http_archive_ext_deps/MODULE.bazel
index e9313837e..e193d99c1 100644
--- a/examples/http_archive_ext_deps/MODULE.bazel
+++ b/examples/http_archive_ext_deps/MODULE.bazel
@@ -7,7 +7,7 @@ local_path_override(
path = "../..",
)
-bazel_dep(name = "cgrindel_bazel_starlib", version = "0.16.2")
+bazel_dep(name = "cgrindel_bazel_starlib", version = "0.17.0")
bazel_dep(name = "bazel_skylib", version = "1.4.2")
bazel_dep(
name = "rules_swift",
diff --git a/examples/interesting_deps/MODULE.bazel b/examples/interesting_deps/MODULE.bazel
index 2403c56fe..e086870b6 100644
--- a/examples/interesting_deps/MODULE.bazel
+++ b/examples/interesting_deps/MODULE.bazel
@@ -12,7 +12,7 @@ local_path_override(
path = "../..",
)
-bazel_dep(name = "cgrindel_bazel_starlib", version = "0.16.2")
+bazel_dep(name = "cgrindel_bazel_starlib", version = "0.17.0")
bazel_dep(name = "bazel_skylib", version = "1.4.2")
bazel_dep(
name = "rules_swift",
diff --git a/examples/ios_sim/MODULE.bazel b/examples/ios_sim/MODULE.bazel
index 292da43df..ceb606a79 100644
--- a/examples/ios_sim/MODULE.bazel
+++ b/examples/ios_sim/MODULE.bazel
@@ -7,7 +7,7 @@ local_path_override(
path = "../..",
)
-bazel_dep(name = "cgrindel_bazel_starlib", version = "0.16.2")
+bazel_dep(name = "cgrindel_bazel_starlib", version = "0.17.0")
bazel_dep(name = "bazel_skylib", version = "1.4.2")
bazel_dep(
name = "rules_swift",
diff --git a/examples/objc_code/MODULE.bazel b/examples/objc_code/MODULE.bazel
index 24be3014b..a256c9b85 100644
--- a/examples/objc_code/MODULE.bazel
+++ b/examples/objc_code/MODULE.bazel
@@ -12,7 +12,7 @@ local_path_override(
path = "../..",
)
-bazel_dep(name = "cgrindel_bazel_starlib", version = "0.16.2")
+bazel_dep(name = "cgrindel_bazel_starlib", version = "0.17.0")
bazel_dep(name = "bazel_skylib", version = "1.4.2")
bazel_dep(
name = "rules_swift",
diff --git a/examples/phone_number_kit/MODULE.bazel b/examples/phone_number_kit/MODULE.bazel
index 9db42083a..096b59016 100644
--- a/examples/phone_number_kit/MODULE.bazel
+++ b/examples/phone_number_kit/MODULE.bazel
@@ -7,7 +7,7 @@ local_path_override(
path = "../..",
)
-bazel_dep(name = "cgrindel_bazel_starlib", version = "0.16.2")
+bazel_dep(name = "cgrindel_bazel_starlib", version = "0.17.0")
bazel_dep(name = "bazel_skylib", version = "1.4.2")
bazel_dep(
name = "rules_swift",
diff --git a/examples/pkg_manifest_minimal/MODULE.bazel b/examples/pkg_manifest_minimal/MODULE.bazel
index 908cda531..eda99f61b 100644
--- a/examples/pkg_manifest_minimal/MODULE.bazel
+++ b/examples/pkg_manifest_minimal/MODULE.bazel
@@ -7,7 +7,7 @@ local_path_override(
path = "../..",
)
-bazel_dep(name = "cgrindel_bazel_starlib", version = "0.16.2")
+bazel_dep(name = "cgrindel_bazel_starlib", version = "0.17.0")
bazel_dep(name = "bazel_skylib", version = "1.4.2")
bazel_dep(
name = "rules_swift",
diff --git a/examples/resources_example/MODULE.bazel b/examples/resources_example/MODULE.bazel
index 75d4ff77d..4f8cc19cf 100644
--- a/examples/resources_example/MODULE.bazel
+++ b/examples/resources_example/MODULE.bazel
@@ -7,7 +7,7 @@ local_path_override(
path = "../..",
)
-bazel_dep(name = "cgrindel_bazel_starlib", version = "0.16.2")
+bazel_dep(name = "cgrindel_bazel_starlib", version = "0.17.0")
bazel_dep(name = "bazel_skylib", version = "1.4.2")
bazel_dep(
name = "rules_swift",
diff --git a/examples/snapkit_example/MODULE.bazel b/examples/snapkit_example/MODULE.bazel
index 743c58bd7..e37051fd8 100644
--- a/examples/snapkit_example/MODULE.bazel
+++ b/examples/snapkit_example/MODULE.bazel
@@ -7,7 +7,7 @@ local_path_override(
path = "../..",
)
-bazel_dep(name = "cgrindel_bazel_starlib", version = "0.16.2")
+bazel_dep(name = "cgrindel_bazel_starlib", version = "0.17.0")
bazel_dep(name = "bazel_skylib", version = "1.4.2")
bazel_dep(
name = "rules_swift",
diff --git a/examples/soto_example/MODULE.bazel b/examples/soto_example/MODULE.bazel
index 4de6bc1a3..801f0514b 100644
--- a/examples/soto_example/MODULE.bazel
+++ b/examples/soto_example/MODULE.bazel
@@ -7,7 +7,7 @@ local_path_override(
path = "../..",
)
-bazel_dep(name = "cgrindel_bazel_starlib", version = "0.16.2")
+bazel_dep(name = "cgrindel_bazel_starlib", version = "0.17.0")
bazel_dep(name = "bazel_skylib", version = "1.4.2")
bazel_dep(
name = "rules_swift",
diff --git a/examples/stripe_example/MODULE.bazel b/examples/stripe_example/MODULE.bazel
index bb8b63e86..98bdaca96 100644
--- a/examples/stripe_example/MODULE.bazel
+++ b/examples/stripe_example/MODULE.bazel
@@ -7,7 +7,7 @@ local_path_override(
path = "../..",
)
-bazel_dep(name = "cgrindel_bazel_starlib", version = "0.16.2")
+bazel_dep(name = "cgrindel_bazel_starlib", version = "0.17.0")
bazel_dep(name = "bazel_skylib", version = "1.4.2")
bazel_dep(
name = "rules_swift",
diff --git a/examples/tca_example/MODULE.bazel b/examples/tca_example/MODULE.bazel
index 5b1457898..0c6fe7e20 100644
--- a/examples/tca_example/MODULE.bazel
+++ b/examples/tca_example/MODULE.bazel
@@ -7,7 +7,7 @@ local_path_override(
path = "../..",
)
-bazel_dep(name = "cgrindel_bazel_starlib", version = "0.16.2")
+bazel_dep(name = "cgrindel_bazel_starlib", version = "0.17.0")
bazel_dep(name = "bazel_skylib", version = "1.4.2")
bazel_dep(
name = "rules_swift",
diff --git a/examples/vapor_example/MODULE.bazel b/examples/vapor_example/MODULE.bazel
index 1680d065b..77d3496dc 100644
--- a/examples/vapor_example/MODULE.bazel
+++ b/examples/vapor_example/MODULE.bazel
@@ -7,7 +7,7 @@ local_path_override(
path = "../..",
)
-bazel_dep(name = "cgrindel_bazel_starlib", version = "0.16.2")
+bazel_dep(name = "cgrindel_bazel_starlib", version = "0.17.0")
bazel_dep(name = "bazel_skylib", version = "1.4.2")
bazel_dep(
name = "rules_swift",
diff --git a/examples/xcmetrics_example/MODULE.bazel b/examples/xcmetrics_example/MODULE.bazel
index efbba2362..86b9d9e9e 100644
--- a/examples/xcmetrics_example/MODULE.bazel
+++ b/examples/xcmetrics_example/MODULE.bazel
@@ -7,7 +7,7 @@ local_path_override(
path = "../..",
)
-bazel_dep(name = "cgrindel_bazel_starlib", version = "0.16.2")
+bazel_dep(name = "cgrindel_bazel_starlib", version = "0.17.0")
bazel_dep(name = "bazel_skylib", version = "1.4.2")
bazel_dep(
name = "rules_swift",
diff --git a/tools/create_example/template_files/MODULE.bazel b/tools/create_example/template_files/MODULE.bazel
index f546202bf..c1da67d28 100644
--- a/tools/create_example/template_files/MODULE.bazel
+++ b/tools/create_example/template_files/MODULE.bazel
@@ -7,7 +7,7 @@ local_path_override(
path = "../..",
)
-bazel_dep(name = "cgrindel_bazel_starlib", version = "0.16.2")
+bazel_dep(name = "cgrindel_bazel_starlib", version = "0.17.0")
bazel_dep(name = "bazel_skylib", version = "1.4.2")
bazel_dep(
name = "rules_swift",
diff --git a/tools/update_go_repos/main.go b/tools/update_go_repos/main.go
index 208b61dd9..653526687 100644
--- a/tools/update_go_repos/main.go
+++ b/tools/update_go_repos/main.go
@@ -63,6 +63,10 @@ This utility updates the Go repositories for this repo wrapping them in 'maybe'
"run", gazelleBinTarget, "--", "update-repos",
fmt.Sprintf("-from_file=%s", fromFile),
fmt.Sprintf("-to_macro=%s%%%s", goDepsFile, macroName),
+ // Need to tell Gazelle to run as if it is in bzlmod mode. It does not figure it out
+ // properly when we run it from inside this binary.
+ // Related to https://github.com/bazelbuild/bazel-gazelle/pull/1589.
+ "-bzlmod",
}
if buildExternal != "" {
args = append(args, fmt.Sprintf("-build_external=%s", buildExternal))
@@ -79,5 +83,14 @@ This utility updates the Go repositories for this repo wrapping them in 'maybe'
return fmt.Errorf("failed updating deps file with maybe declarations: %w", err)
}
+ // GH557: HACK Revert changes made to the WORKSPACE.
+ // This hack can be removed post v0.32.0. We are waiting for the following fix to be released:
+ // https://github.com/bazelbuild/bazel-gazelle/pull/1589
+ wkspFile := path.Join(repoRoot, "WORKSPACE")
+ wkspContents := "# Intentionally blank: use bzlmod\n"
+ if err := os.WriteFile(wkspFile, []byte(wkspContents), 0666); err != nil {
+ return fmt.Errorf("failed reverting changes to the WORKSPACE file: %w", err)
+ }
+
return nil
}