Skip to content
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

Bazel 8 compatibility (fork of #283) #284

Closed
wants to merge 18 commits into from
Closed
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
5 changes: 4 additions & 1 deletion .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
---

matrix:
bazel: [
7.4.1,
# last_green, # Enable this once WORKSPACE builds with Bazel 8 work.
8.0.0rc4,
last_green,
]

tools_flags: &tools_flags
Expand Down
37 changes: 18 additions & 19 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module(

bazel_dep(name = "platforms", version = "0.0.5")
bazel_dep(name = "rules_license", version = "1.0.0")
bazel_dep(name = "rules_java", version = "7.12.2")
bazel_dep(name = "rules_java", version = "8.5.1")
bazel_dep(name = "rules_shell", version = "0.1.2")

bazel_dep(name = "stardoc", version = "0.6.2", dev_dependency = True)
Expand All @@ -21,22 +21,28 @@ git_override(
rules_java_toolchains = use_extension("@rules_java//java:extensions.bzl", "toolchains")
use_repo(rules_java_toolchains, "remote_java_tools")

bazel_dep(name = "protobuf", version = "29.0-rc2.bcr.1", repo_name = "com_google_protobuf")
bazel_dep(name = "rules_jvm_external", version = "6.5")
bazel_dep(name = "protobuf", repo_name = "com_google_protobuf", version = "29.0")
bazel_dep(name = "rules_jvm_external", version = "6.6")
bazel_dep(name = "bazel_skylib", version = "1.0.3")
bazel_dep(name = "rules_robolectric", version = "4.13", repo_name = "robolectric")
bazel_dep(name = "rules_robolectric", version = "4.14.1", repo_name = "robolectric")
# To include PR #123
git_override(
module_name = "rules_robolectric",
remote = "https://github.com/robolectric/robolectric-bazel",
commit = "f38b7365361f382ecdad255af69b37413dd48ead",
)

register_toolchains("//toolchains/android:all")

register_toolchains("//toolchains/android_sdk:all")

# go-related dependency setup
bazel_dep(name = "rules_go", version = "0.50.1", repo_name = "io_bazel_rules_go")
bazel_dep(name = "gazelle", version = "0.28.0", repo_name = "bazel_gazelle")
bazel_dep(name = "rules_go", version = "0.51.0-rc2", repo_name = "io_bazel_rules_go")
bazel_dep(name = "gazelle", version = "0.40.0", repo_name = "bazel_gazelle")
bazel_dep(name = "abseil-py", version = "2.1.0", repo_name = "py_absl")

bazel_dep(name = "bazel_worker_api", version = "0.0.2")
bazel_dep(name = "bazel_worker_java", version = "0.0.2")
bazel_dep(name = "bazel_worker_api", version = "0.0.4")
bazel_dep(name = "bazel_worker_java", version = "0.0.4")

go_sdk = use_extension("@io_bazel_rules_go//go:extensions.bzl", "go_sdk")

Expand Down Expand Up @@ -85,16 +91,16 @@ maven.install(
"com.android.tools:r8:8.3.37",
"org.bouncycastle:bcprov-jdk18on:1.77",
"org.hamcrest:hamcrest-core:2.2",
"org.robolectric:robolectric:4.10.3",
"org.robolectric:robolectric:4.14.1",
"com.google.flogger:flogger:0.8",
"com.google.guava:guava:32.1.2-jre",
"com.google.truth:truth:1.1.5",
"info.picocli:picocli:4.7.4",
"jakarta.inject:jakarta.inject-api:2.0.1",
"junit:junit:4.13.2",
"com.beust:jcommander:1.82",
"com.google.protobuf:protobuf-java:4.29.0-RC2",
"com.google.protobuf:protobuf-java-util:4.29.0-RC2",
"com.google.protobuf:protobuf-java:4.29.0",
"com.google.protobuf:protobuf-java-util:4.29.0",
"com.google.code.findbugs:jsr305:3.0.2",
"androidx.databinding:databinding-compiler:8.7.0",
"org.ow2.asm:asm:9.6",
Expand Down Expand Up @@ -146,7 +152,7 @@ use_repo(remote_android_extensions, "android_gmaven_r8", "android_tools")
# integration test setup
bazel_dep(
name = "rules_bazel_integration_test",
version = "0.26.0",
version = "0.27.0",
dev_dependency = True,
)
bazel_dep(
Expand All @@ -167,13 +173,6 @@ use_repo(bazel_binaries, "bazel_binaries")
apksig_extension = use_extension("//bzlmod_extensions:apksig.bzl", "apksig_extension")
use_repo(apksig_extension, "apksig")

# To include PR #92
git_override(
module_name = "rules_robolectric",
remote = "https://github.com/robolectric/robolectric-bazel",
commit = "a5b25a8c27cc6add74bb01e62cd0dc72df8933ff",
)

android_sdk_repository_extension = use_extension("//rules/android_sdk_repository:rule.bzl", "android_sdk_repository_extension")
use_repo(android_sdk_repository_extension, "androidsdk")

Expand Down
45 changes: 20 additions & 25 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,35 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")

load("prereqs.bzl", "rules_android_prereqs")
rules_android_prereqs(dev_mode = True)

# Required by protobuf and rules_proto
BAZEL_FEATURES_VERSION = "1.20.0"
BAZEL_FEATURES_HASH = "c2596994cf63513bd44180411a4ac3ae95d32bf59148fcb6087a4642b3ffef11"
maybe(
http_archive,
name = "bazel_features",
sha256 = BAZEL_FEATURES_HASH,
strip_prefix = "bazel_features-" + BAZEL_FEATURES_VERSION,
url = "https://github.com/bazel-contrib/bazel_features/releases/download/v" + BAZEL_FEATURES_VERSION + "/bazel_features-v" + BAZEL_FEATURES_VERSION + ".tar.gz",
)
maybe(
http_archive,
name = "proto_bazel_features",
sha256 = BAZEL_FEATURES_HASH,
strip_prefix = "bazel_features-" + BAZEL_FEATURES_VERSION,
url = "https://github.com/bazel-contrib/bazel_features/releases/download/v" + BAZEL_FEATURES_VERSION + "/bazel_features-v" + BAZEL_FEATURES_VERSION + ".tar.gz",
)
load("@bazel_features//:deps.bzl", "bazel_features_deps")
bazel_features_deps()
load("@rules_java//java:rules_java_deps.bzl", "rules_java_dependencies")
rules_java_dependencies()
# note that the following line is what is minimally required from protobuf for the java rules
# consider using the protobuf_deps() public API from @com_google_protobuf//:protobuf_deps.bzl
load("@com_google_protobuf//bazel/private:proto_bazel_features.bzl", "proto_bazel_features") # buildifier: disable=bzl-visibility
proto_bazel_features(name = "proto_bazel_features")
# register toolchains
load("@rules_java//java:repositories.bzl", "rules_java_toolchains")
rules_java_toolchains()

rules_android_prereqs(dev_mode = True)
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
protobuf_deps()

load("//rules:rules.bzl", "android_sdk_repository")
load("@rules_jvm_external//:repositories.bzl", "rules_jvm_external_deps")
rules_jvm_external_deps()
load("@rules_jvm_external//:setup.bzl", "rules_jvm_external_setup")
rules_jvm_external_setup()

load("defs_dev.bzl", "rules_android_workspace")
rules_android_workspace()

load("//rules:rules.bzl", "android_sdk_repository")
maybe(
android_sdk_repository,
name = "androidsdk",
)

load("defs_dev.bzl", "rules_android_workspace")

rules_android_workspace()

register_toolchains("//toolchains/android:all")

register_toolchains("//toolchains/android_sdk:all")
21 changes: 12 additions & 9 deletions defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,32 @@

load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository")
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
load("@protobuf//:protobuf_deps.bzl", "protobuf_deps")
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
load(
"@io_bazel_rules_go//go:deps.bzl",
"go_download_sdk",
"go_register_toolchains",
"go_rules_dependencies",
)
load("@robolectric//bazel:robolectric.bzl", "robolectric_repositories")
load("@rules_java//java:repositories.bzl", "rules_java_dependencies", "rules_java_toolchains")
load("@rules_jvm_external//:defs.bzl", "maven_install")
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies")
load("@rules_proto//proto:toolchains.bzl", "rules_proto_toolchains")
load("@rules_proto//proto:setup.bzl", "rules_proto_setup")
load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains")
load("@rules_shell//shell:repositories.bzl", "rules_shell_dependencies", "rules_shell_toolchains")
load("@bazel_features//:deps.bzl", "bazel_features_deps")

def rules_android_workspace():
""" Sets up workspace dependencies for rules_android."""
bazel_skylib_workspace()


bazel_features_deps()

protobuf_deps()

bazel_skylib_workspace()

maven_install(
name = "rules_android_maven",
artifacts = [
Expand All @@ -55,16 +60,16 @@ def rules_android_workspace():
"com.android.tools:r8:8.3.37",
"org.bouncycastle:bcprov-jdk18on:1.77",
"org.hamcrest:hamcrest-core:2.2",
"org.robolectric:robolectric:4.10.3",
"org.robolectric:robolectric:4.14.1",
"com.google.flogger:flogger:0.8",
"com.google.guava:guava:32.1.2-jre",
"com.google.truth:truth:1.1.5",
"info.picocli:picocli:4.7.4",
"jakarta.inject:jakarta.inject-api:2.0.1",
"junit:junit:4.13.2",
"com.beust:jcommander:1.82",
"com.google.protobuf:protobuf-java:4.29.0-RC2",
"com.google.protobuf:protobuf-java-util:4.29.0-RC2",
"com.google.protobuf:protobuf-java:4.29.0-RC3",
"com.google.protobuf:protobuf-java-util:4.29.0-RC3",
"com.google.code.findbugs:jsr305:3.0.2",
"androidx.databinding:databinding-compiler:8.7.0",
"org.ow2.asm:asm:9.6",
Expand Down Expand Up @@ -174,11 +179,9 @@ def rules_android_workspace():

robolectric_repositories()

rules_java_dependencies()
rules_java_toolchains()

rules_proto_dependencies()
rules_proto_toolchains()
rules_proto_setup()

py_repositories()

Expand Down
71 changes: 19 additions & 52 deletions examples/basicapp/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -5,64 +5,32 @@ local_repository(
name = "rules_android",
path = "../..", # rules_android's WORKSPACE relative to this inner workspace
)
# --SNIP--: Everything below this line goes into the example WORKSPACE snippet in the release notes.

# rules_license
http_archive(
name = "rules_license",
urls = [
"https://github.com/bazelbuild/rules_license/releases/download/1.0.0/rules_license-1.0.0.tar.gz",
],
sha256 = "26d4021f6898e23b82ef953078389dd49ac2b5618ac564ade4ef87cced147b38",
)

# rules_jvm_external
RULES_JVM_EXTERNAL_TAG = "6.5"
RULES_JVM_EXTERNAL_SHA = "3a4d56357851cf5b0dae538b3f3e0612a4f58925dfb3cadb2e0c4e87d51e629e"

http_archive(
name = "rules_jvm_external",
strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG,
sha256 = RULES_JVM_EXTERNAL_SHA,
url = "https://github.com/bazelbuild/rules_jvm_external/releases/download/%s/rules_jvm_external-%s.tar.gz" % (RULES_JVM_EXTERNAL_TAG, RULES_JVM_EXTERNAL_TAG)
)

# bazel_features
BAZEL_FEATURES_VERSION = "1.20.0"
BAZEL_FEATURES_HASH = "c2596994cf63513bd44180411a4ac3ae95d32bf59148fcb6087a4642b3ffef11"
maybe(
http_archive,
name = "bazel_features",
sha256 = BAZEL_FEATURES_HASH,
strip_prefix = "bazel_features-" + BAZEL_FEATURES_VERSION,
url = "https://github.com/bazel-contrib/bazel_features/releases/download/v" + BAZEL_FEATURES_VERSION + "/bazel_features-v" + BAZEL_FEATURES_VERSION + ".tar.gz",
)
maybe(
http_archive,
name = "proto_bazel_features",
sha256 = BAZEL_FEATURES_HASH,
strip_prefix = "bazel_features-" + BAZEL_FEATURES_VERSION,
url = "https://github.com/bazel-contrib/bazel_features/releases/download/v" + BAZEL_FEATURES_VERSION + "/bazel_features-v" + BAZEL_FEATURES_VERSION + ".tar.gz",
)
load("@bazel_features//:deps.bzl", "bazel_features_deps")
bazel_features_deps()

# Skylib
http_archive(
name = "bazel_skylib",
sha256 = "bc283cdfcd526a52c3201279cda4bc298652efa898b10b4db0837dc51652756f",
urls = [
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.7.1/bazel-skylib-1.7.1.tar.gz",
],
)
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
bazel_skylib_workspace()
# --SNIP--: Everything below this line goes into the example WORKSPACE snippet in the release notes.

# Android rules dependencies
load("@rules_android//:prereqs.bzl", "rules_android_prereqs")
rules_android_prereqs()

load("@rules_java//java:rules_java_deps.bzl", "rules_java_dependencies")
rules_java_dependencies()
# note that the following line is what is minimally required from protobuf for the java rules
# consider using the protobuf_deps() public API from @com_google_protobuf//:protobuf_deps.bzl
load("@com_google_protobuf//bazel/private:proto_bazel_features.bzl", "proto_bazel_features") # buildifier: disable=bzl-visibility
proto_bazel_features(name = "proto_bazel_features")
# register toolchains
load("@rules_java//java:repositories.bzl", "rules_java_toolchains")
rules_java_toolchains()

load("@rules_jvm_external//:repositories.bzl", "rules_jvm_external_deps")
rules_jvm_external_deps()
load("@rules_jvm_external//:setup.bzl", "rules_jvm_external_setup")
rules_jvm_external_setup()

load("@rules_android//:defs.bzl", "rules_android_workspace")
rules_android_workspace()

# Android SDK setup
load("@rules_android//rules:rules.bzl", "android_sdk_repository")
android_sdk_repository(
name = "androidsdk",
Expand All @@ -72,4 +40,3 @@ register_toolchains(
"@rules_android//toolchains/android:android_default_toolchain",
"@rules_android//toolchains/android_sdk:android_sdk_tools",
)

Loading