bzlmod support
Closed this issue · 12 comments
Currently fails with this:
no such target '//external:databinding_annotation_processor': target 'databinding_annotation_processor' not declared in package 'external' defined by <workspace path>/WORKSPACE (Tip: use `query "//external:*"` to see all the targets in that package) and referenced by '@bazel_tools//tools/android:databinding_annotation_processor'
I think that's referenced here:
https://github.com/bazelbuild/bazel/blob/d0e29582a2e788e8acdaf53fe30ab7f7dc592df3/tools/android/BUILD.tools#L448
For the starlark rules at least, I think we can point them here instead:
rules_android/tools/android/BUILD
Line 35 in a6b9b79
Hm, we appear to already be doing that:
So probably coming from the parts of android_binary that are still in native:
rules_android/rules/android_binary.bzl
Line 43 in a6b9b79
But I think we could replace this:
with this:
rules_android/tools/android/BUILD
Lines 34 to 42 in a6b9b79
and change the name to match the existing alias, it should "just work"
Hi folks,
quick question - i'm new to bzlmod and trying to setup my android project using bzlmod.
I'm not sure if there's an equivalent to WORKSPACE's android_sdk_repository
in bzlmod? When i try to build android_library
targets with my MODULE.bazel depending on rules_android
module i run into the following error:
While resolving toolchains for target //:sample: No matching toolchains found for types @bazel_tools//tools/android:sdk_toolchain_type.
Wondering if this is related to this issue. i.e. it's not possible yet to setup android projects using bzlmod?
@telescopic Bzlmod works now but you will need to be using the latest Bazel rolling release until the actual fix get backported into the 6.x release track.
@Bencodes thanks for your reply - is there any documentation surrounding the same?
@telescopic not much documentation right now.
Bzlmod doesn't actually seem to be fully working if you are using rules_android
at HEAD. If you are still using the native rules it's possible to get everything working. Example: https://github.com/robolectric/robolectric-bazel/tree/master/examples/simple
bzlmod support doesn't seem to be working at all:
I created a minimal example showing that following the basic instructions on the main README here leads to the repo not being found.
EDIT
Huh apparently I had a problem with my bazelrc (failed to include line-continuations), adding those in so the flags were all present I ended up with a different error:
ERROR: no such package '@@android_gmaven_r8//jar': The repository '@@android_gmaven_r8' could not be resolved: Repository '@@android_gmaven_r8' is not defined
ERROR: D:/_bazel_out/lbijidmj/external/androidsdk/BUILD.bazel:31:25: no such package '@@android_gmaven_r8//jar': The repository '@@android_gmaven_r8' could not be resolved: Repository '@@android_gmaven_r8' is not defined and referenced by
'@@androidsdk//:d8_jar_import'
Hi @bdleitner,
The README is sadly not entirely up to date, especially for bzlmod integration. We will address documentation shortcomings later this year as part of the overall rules maturation process. I have a change in progress that adds the following lines to MODULE.bazel for the example app that should address the issue you're seeing.
remote_android_extensions = use_extension("@bazel_tools//tools/android:android_extensions.bzl", "remote_android_tools_extensions")
use_repo(remote_android_extensions, "android_gmaven_r8", "android_tools")
bzlmod and BCR is now supported with 0.5.0 release