-
-
Notifications
You must be signed in to change notification settings - Fork 256
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
Update rules_jvm_external to use the Starlark version of aar_import after the native version was removed from Bazel #1149
Conversation
Oh, I just noticed the tests run on bazel as far back as bazel 5.4.0: The starlark Android rules will only work with 7.2.0 (releasing soon). Might need to segment the tests so that the tests with the starlark version of aar_import are only run with 7.2.0 |
The windows tests will also be a problem because windows support for starlark rules_android is low priority |
We still need to support Windows users, so those tests will need to pass properly before we can land this PR. |
bazelbuild/rules_android#235 should fix up the windows problems |
Error looks legit:
from https://buildkite.com/bazel/rules-jvm-external/builds/4289#018fc5e0-bc05-4701-80b8-55fdf1f6ddb0 (and others) |
That's fixed in 7.2.0, specifically bazelbuild/bazel#22416, but there are other problems revealed after bazelbuild/rules_android#235 I'll make this a draft until CI is passing |
…utomatically if the version of Bazel used does not contain the native version of aar_import. This also updates the version of rules_android to the latest commit, because version 0.1.1 is basically just wrappers around the native versions of the rules. This also disbles `--experimental_sibling_repository_layout` added in bazel-contrib@b6631f9 because the latest rules_android uses protos in go, and there is a problem compiling protos in go with `--experimental_sibling_repository_layout`: bazel-contrib/rules_go#3947 Fixes bazel-contrib#1139.
The tests now work with the latest version of bazel: and the others are failing due to an older version of bazel being used and incompatible visibility on some targets in |
We do need the CI tests to pass before we can land this. We're fine asking for the latest versions of Bazel 5 and 6, but our version 7 support is more flexible. |
… of rules_android that rules_kotlin uses
Right I wouldn't want to submit something that breaks CI :)
After going through most of the initial issues, it looks like the starlark android rules won't work with bazel 5 because at minimum they use https://github.com/search?q=repo%3Abazelbuild%2Frules_android+%22visibility%28%22&type=code I might be able to get the rules to work with bazel 6, but I'm not sure how long we can guarantee that (really we've only been developing for bazel 8 and backporting some things as needed to bazel 7). Maybe I can arrange this so that the native android rules are used with the tests that use bazel 5 and bazel 6, and the starlark rules with latest bazel (8+). That might just amount to removing the |
…rectly" because Starlark aar_import checks that there are no missing class imports in aars
…rt regression_testing_coursier_install.json
… use with bazel 5 and bazel 6 in CI
This stubbed out action is failing on windows: So that will have to be another update in rules_android But it looks like everything else is working: native android rules on bazel 5 / 6, starlark android rules on 7+ |
Ran into this while getting rules_jvm_export and the rules_android working together: bazel-contrib/rules_jvm_external#1149 (comment) PiperOrigin-RevId: 651557752 Change-Id: I30bbe6792863b7d5ed178f0d074a3bf73eb631db
Hm, well bazelbuild/rules_android@746589b should have fixed the windows tests, but looks like the ValidateAAR action is still failing... I'll have to try something else but out of time today. Really that action does nothing (it's just a stub action that actually does nothing) so I might just try to disable it |
With bazelbuild/rules_android@f4b6edb all the tests are now passing |
I updated the description and marked this ready for review |
Thank you! |
…import after the native version was removed from Bazel (bazel-contrib#1149)" This reverts commit ba7310c. The default label for AAR imports is `@rules_android//android:rules.bzl`. This imports `@rules_android//rules:providers.bzl`, which calls `@rules_android//rules/reexport_providers.bzl`. This means that any downstream user of `rules_jvm_external` with a sufficiently recent version of Bazel needs to add `build --experimental_google_legacy_api` to their `.bazelrc` That's a significantly breaking change, and one that it's not reasonable to ask our users to do, especially since the vast majority of projects don't use the Android rules.
…import after the native version was removed from Bazel (#1149)" (#1215) This reverts commit ba7310c. The default label for AAR imports is `@rules_android//android:rules.bzl`. This imports `@rules_android//rules:providers.bzl`, which calls `@rules_android//rules/reexport_providers.bzl`. This means that any downstream user of `rules_jvm_external` with a sufficiently recent version of Bazel needs to add `build --experimental_google_legacy_api` to their `.bazelrc` That's a significantly breaking change, and one that it's not reasonable to ask our users to do, especially since the vast majority of projects don't use the Android rules.
The native version of
aar_import
has been removed from bazel at head, so use the Starlark version instead.This PR:
Updates rules_jvm_external to use the Starlark version of aar_import automatically if the version of Bazel used does not contain the native version of aar_import.
Updates the version of Bazel in
.bazelversion
to 7.2.1 because the latest Starlark Android rules are only compatible with 7.2.1+Updates the version of rules_android used to the latest commit, because version 0.1.1 is basically just wrappers around the native versions of the rules. However, version 0.1.1 of rules_android is still used in the
WORKSPACE
file so that test that run with Bazel 5 and Bazel 6 use the native rules, and Bazel 7+ uses the Starlark rules via bzlmod /MODULE.bazel
, because the latest version of the Starlark rules are only compatible with Bazel 7.2.1+.Updates the default label to import aar_import from, from
@build_bazel_rules_android//android:rules.bzl
to@rules_android//rules:rules.bzl
, both to match the bzlmod style name of the repo ("rules_android") and to use the latest label inside the repo (//android:rules.bzl
exists, but only for backwards compatibility).Fixes some dependency issues with
aar_import_that_consumes_the_downloaded_file_directly
andsceneform_rendering
aar_import
s, because the Starlark version ofaar_import
performs additional checks ("ImportDepsChecker") to ensure that the dependencies of every class in the imported aar are in the dependencies. Notably, the classcom.google.ar.sceneform.assets.Loader
is used somewhere in the aar or its dependencies, but I couldn't find this class anywhere in any aars on maven.google.com, so I ended up having to stub it out with an empty implementation to satisfy the check.Disables
--experimental_sibling_repository_layout
added in b6631f9 because the latest rules_android uses protos in go, and there is a problem compiling protos in go with--experimental_sibling_repository_layout
: rules_go + protobufs + experimental_sibling_repository_layout fails to build rules_go#3947Adds
--experimental_google_legacy_api
to.bazelrc
until Remove dependencies on --experimental_google_legacy_api and --experimental_enable_android_migration_apis bazelbuild/rules_android#219 is fixedFixes #1139.