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

Make robolectric-bazel work for bazel 6 and 7 #123

Merged
merged 2 commits into from
Dec 4, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-2022, macos-13]
bazel: [7.4.1, 8.0.0rc4]
bazel: [6.5.0, 7.4.1, 8.0.0rc7]
bzlmod: [ true, false ]
runs-on: ${{ matrix.os }}
steps:
Expand Down
15 changes: 14 additions & 1 deletion bazel/BUILD
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
load("@rules_java//java:java_import.bzl", "java_import")
load("@rules_java//java:java_library.bzl", "java_library")
load("@rules_python//python:py_binary.bzl", "py_binary")
load(":robolectric.bzl", "DEFAULT_AVAILABLE_VERSIONS")
Expand All @@ -8,7 +9,19 @@ package(
],
)

_ANDROID_ALL_JARS = ["@{}//jar".format(v.name) for v in DEFAULT_AVAILABLE_VERSIONS]
[
java_import(
name = "import_" + v.name,
jars = ["@{}//file".format(v.name)],
visibility = [
":__pkg__",
"//tests:__subpackages__",
],
)
for v in DEFAULT_AVAILABLE_VERSIONS
]

_ANDROID_ALL_JARS = ["import_{}".format(v.name) for v in DEFAULT_AVAILABLE_VERSIONS]

java_library(
name = "android-all",
Expand Down
4 changes: 2 additions & 2 deletions bazel/robolectric.bzl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Robolectric repositories
"""

load("@rules_java//java:http_jar.bzl", "http_jar")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file")

def robolectric_version(version, sha256, url = None):
"""Define a struct representation of an instrumented Robolectric jar.
Expand Down Expand Up @@ -92,4 +92,4 @@ def robolectric_repositories():
"""Creates http_jar repositories for the given versions of Robolectric.
"""
for v in DEFAULT_AVAILABLE_VERSIONS:
http_jar(name = v.name, url = v.url, downloaded_file_name = "android-all-instrumented-%s.jar" % (v.version), sha256 = v.sha256)
http_file(name = v.name, url = v.url, downloaded_file_path = "android-all-instrumented-%s.jar" % (v.version), sha256 = v.sha256)
Loading