Skip to content

Enable Bzlmod #1722

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Apr 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,14 @@ tasks:
# Install xmllint
- sudo apt update && sudo apt install --reinstall libxml2-utils -y
- "./test_rules_scala.sh"
# Switch `last_rc` to `last_green` once Bzlmod lands.
# https://github.com/bazelbuild/rules_scala/issues/1482
test_rules_scala_linux_last_rc:
name: "./test_rules_scala (last_rc Bazel)"
test_rules_scala_linux_last_green:
name: "./test_rules_scala (last_green Bazel)"
platform: ubuntu2004
bazel: last_rc
bazel: last_green
shell_commands:
# Install xmllint
- sudo apt update && sudo apt install --reinstall libxml2-utils -y
- echo "build --enable_workspace" >> .bazelrc
- "./test_rules_scala.sh || buildkite-agent annotate --style 'warning' \"Optional build with last_rc Bazel version failed, [see here](${BUILDKITE_BUILD_URL}#${BUILDKITE_JOB_ID}) (It is not mandatory but worth checking)\""
- "./test_rules_scala.sh || buildkite-agent annotate --style 'warning' \"Optional build with last_green Bazel version failed, [see here](${BUILDKITE_BUILD_URL}#${BUILDKITE_JOB_ID}) (It is not mandatory but worth checking)\""
test_rules_scala_macos:
name: "./test_rules_scala"
platform: macos
Expand Down Expand Up @@ -104,10 +101,10 @@ tasks:
shell_commands:
- "./test_cross_build.sh"
lint_linux:
name: "bazel //tools:lint_check"
name: "./test_lint.sh"
platform: ubuntu2004
run_targets:
- "//tools:lint_check"
shell_commands:
- "./test_lint.sh"
test_rules_scala_jdk21:
name: "./test_rules_scala with jdk21"
platform: ubuntu2004
Expand Down
19 changes: 19 additions & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Remove once the following is fixed:
# - bazelbuild/bazel: Loading top-level targets in local_path_override modules
# in child directory breaks the build #22208
# https://github.com/bazelbuild/bazel/issues/22208
dt_patches/compiler_sources
dt_patches/test_dt_patches
dt_patches/test_dt_patches_user_srcjar
examples/crossbuild
examples/overridden_artifacts
examples/scala3
examples/semanticdb
examples/testing/multi_frameworks_toolchain
examples/testing/scalatest_repositories
examples/testing/specs2_junit_repositories
test/proto_cross_repo_boundary/repo
test_cross_build
third_party/test/example_external_workspace
third_party/test/new_local_repo
third_party/test/proto
7 changes: 3 additions & 4 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# Switch to --noenable_workspace when Bzlmod lands.
# https://github.com/bazelbuild/rules_scala/issues/1482
common --enable_workspace --noenable_bzlmod
# Remove once Bazel 8 becomes the minimum supported version.
common --noenable_workspace --incompatible_use_plus_in_repo_names

# Remove once proto toolchainization becomes the default
# Remove if protocol compiler toolchainization ever becomes the default.
# - https://bazel.build/reference/command-line-reference#flag--incompatible_enable_proto_toolchain_resolution
# - https://docs.google.com/document/d/1CE6wJHNfKbUPBr7-mmk_0Yo3a4TaqcTPE0OWNuQkhPs/edit
common --incompatible_enable_proto_toolchain_resolution
Expand Down
16 changes: 16 additions & 0 deletions .bcr/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Bazel Central Registry publication

The [Publish to BCR GitHub app](https://github.com/bazel-contrib/publish-to-bcr)
uses these configuration files for publishing Bazel modules to the [Bazel
Central Registry (BCR)](https://registry.bazel.build/).

- [Publish to BCR workflow setup](
https://github.com/bazel-contrib/publish-to-bcr/tree/main/README.md#setup)
- [.bcr/ templates](
https://github.com/bazel-contrib/publish-to-bcr/tree/main/templates)

Related documentation:

- [bazelbuild/bazel-central-registry](
https://github.com/bazelbuild/bazel-central-registry)
- [GitHub Actions](https://docs.github.com/actions)
20 changes: 20 additions & 0 deletions .bcr/metadata.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"homepage": "https://github.com/bazelbuild/rules_scala",
"maintainers": [
{
"name": "Simonas Pinevičius",
"email": "[email protected]",
"github": "simuons"
},
{
"name": "Vaidas Pilkauskas",
"email": "[email protected]",
"github": "liucijus"
}
],
"repository": [
"github:bazelbuild/rules_scala"
],
"versions": [],
"yanked_versions": {}
}
14 changes: 14 additions & 0 deletions .bcr/presubmit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
bcr_test_module:
module_path: "examples/crossbuild"
matrix:
platform: ["debian10", "macos", "ubuntu2004", "windows"]
bazel: [7.x, 8.x, rolling, last_green]
tasks:
run_tests:
name: "Build and test the example module"
platform: ${{ platform }}
bazel: ${{ bazel }}
build_targets:
- "//..."
test_targets:
- "//..."
5 changes: 5 additions & 0 deletions .bcr/source.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"integrity": "",
"strip_prefix": "{REPO}-{VERSION}",
"url": "https://github.com/{OWNER}/{REPO}/releases/download/{TAG}/{REPO}-{TAG}.tar.gz"
}
14 changes: 12 additions & 2 deletions .github/workflows/workspace_snippet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,23 @@ set -o errexit -o nounset -o pipefail

# Set by GH actions, see
# https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
TAG=${GITHUB_REF_NAME}
PREFIX="rules_scala-${TAG:1}"
TAG="${GITHUB_REF_NAME}"
VERSION="${TAG:1}"
PREFIX="rules_scala-${VERSION}"
ARCHIVE="rules_scala-$TAG.tar.gz"
git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip > $ARCHIVE
SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}')

cat << EOF
## Using Bzlmod
Paste this snippet into your \`MODULE.bazel\` file:
\`\`\`starlark
# Set \`repo_name = "io_bazel_rules_scala"\` if you still need it.
bazel_dep(name = "rules_scala", version = "${VERSION}")
\`\`\`
## Using WORKSPACE
Paste this snippet into your \`WORKSPACE\` file:
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,9 @@ test/semanticdb/tempsrc

# From scripts/create_repository.py
repository-artifacts.json

# Until it settles down
**/MODULE.bazel.lock

# Used by some tests, but can also be used for local experimentation.
tmp/
Loading