Enable Bzlmod for Bazel
This PR enables Bzlmod as the default external dependencies system for Bazel.
Changes included:
- Enable bzlmod by default in `.bazelrc`.
- Renamed `io_bazel` to `_main` at necessary locations.
- Added lockfile `MODULE.bazel.lock`. We should enable `--lockfile_mode=error` on CI and `--lockfile_mode=update` for local builds after fixing some issues in the lock file feature, probably with 6.4.0.
- Replaced distdir with repository cache (http artifact cache) in the offline bootstrap build. This will eventually be replaced by vendoring and packaging dependencies.
- Replaced `--override_repository` hack with repository cache (http artifact cache) for running integration tests without network access. This will eventually be replaced by a true shared repository cache.
- Only keep `--experimental_repository_cache_hardlinks` for macOS inside integration tests. On Linux, it'll trigger `invalid cross-device link` error because the file system of the sandbox dir is different from the repo cache dir inside docker container.
- Moved common CI flags to .bazelrc for better maintenance.
- Added all Maven coords in MODULE.bazel, patched rules_jvm_external to fix some Bzlmod issues.
Next step:
- Remove WORKSPACE and clean up distdir_deps, distdir.bzl.
- Enable `--lockfile_mode=error` on CI and `--lockfile_mode=update` for local builds
Closes https://github.com/bazelbuild/bazel/pull/19087
Fixes https://github.com/bazelbuild/bazel/issues/18957
PiperOrigin-RevId: 563825184
Change-Id: Ibf06418688bd568b38fd4aa73ad8328acfbaa13c
diff --git a/scripts/bootstrap/bootstrap.sh b/scripts/bootstrap/bootstrap.sh
index befafd5..87b9df5 100755
--- a/scripts/bootstrap/bootstrap.sh
+++ b/scripts/bootstrap/bootstrap.sh
@@ -35,10 +35,13 @@
--nojava_header_compilation \
--strategy=Javac=worker --worker_quit_after_build --ignore_unsupported_sandboxing \
--compilation_mode=opt \
- --distdir=derived/distdir \
+ --repository_cache=derived/repository_cache \
--extra_toolchains=//scripts/bootstrap:all \
--extra_toolchains=@bazel_tools//tools/python:autodetecting_toolchain \
- --override_repository=maven="$(get_cwd)/maven" \
+ --enable_bzlmod \
+ --check_direct_dependencies=error \
+ --lockfile_mode=update \
+ --override_repository=$(cat derived/maven/MAVEN_CANONICAL_REPO_NAME)=derived/maven \
${DIST_BOOTSTRAP_ARGS:-} \
${EXTRA_BAZEL_ARGS:-}"