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

Starlark aar_import does not expose StarlarkAndroidResourcesInfo #77

Open
katre opened this issue May 3, 2023 · 8 comments
Open

Starlark aar_import does not expose StarlarkAndroidResourcesInfo #77

katre opened this issue May 3, 2023 · 8 comments

Comments

@katre
Copy link
Member

katre commented May 3, 2023

Discovered while testing bazelbuild/examples#287.

When building examples/android/ndk with rules_android master branch, the build succeeds. The ManifestMerger action has the --mergeeManfests argument set to a list of manifest files, which includes @maven//\:androidx_appcompat_appcompat,bazel-out/android-arm64-v8a-fastbuild-ST-0b94fd089017/bin/external/maven/androidx_appcompat_appcompat_resources_processed_manifest/AndroidManifest.xml

When building with the pre-alpha branch, the ManifestMerger does not set the flag, and the merge action fails (presumably due to the lack of needed dependencies).

@katre
Copy link
Member Author

katre commented May 3, 2023

Looks like the issue is RourceDependencies.fromRuleDeps, which is looking for the AndroidResourceInfo.PROVIDER provider. This is present with the master branch, but not with the pre-alpha, which I assume is due to starlarkifying android_library.

@katre
Copy link
Member Author

katre commented May 3, 2023

Yes, looks like the native android_library calls AndroidResources.from, which collects the AndroidResourceInfo providers, but the version in pre-alpha does not.

@katre
Copy link
Member Author

katre commented May 3, 2023

Okay, finally figured out the issue.

The pre-alpha version of resource collection (as implemented in rules/resources.bzl only checks for the existence of StarlarkAndroidResourcesInfo, not the native AndroidResourcesInfo.

The Starlark version of aar_import creates this provider, as expected.

However, the code in examples/android/ndk depends on appcompat via maven_install from rules_jvm_external, which creates an aar_import target using the native rules, which uses the native provider.

Either the pre-alpha branch needs to check for both possible providers, or rules_jvm_export needs to use the same pre-alpha version of aar_import, or rules_jvm_export isn't compatible with rules_android pre-alpha.

@katre
Copy link
Member Author

katre commented May 3, 2023

Looks like rules_jvm_external has support for this, possibly.

@katre
Copy link
Member Author

katre commented May 3, 2023

But even using the starlark aar_import, the target @maven//:androidx_appcompat_appcompat doesn't have the StarlarkAndroidResourcesInfo provider.

Using native aar_import to list provider names:

$ /tmp/blazes/bazel cquery --output=starlark --starlark:expr='providers(target).keys()' @maven//:androidx_appcompat_appcompat_resources
[
  "InstrumentedFilesInfo",
  "AndroidResourcesInfo",
  "AndroidManifestInfo",
  "AndroidAssetsInfo",
  "DataBindingV2Info",
  "ProguardSpecProvider",
  "AndroidNativeLibsInfo",
  "JavaInfo",
  "FileProvider",
  "FilesToRunProvider",
  "OutputGroupInfo",
]

Using Starlark aar_import to list provider names:

$ /tmp/blazes/bazel cquery --output=starlark --starlark:expr='providers(target).keys()' @maven//:androidx_appcompat_appcompat_resources
[
  "AndroidLibraryResourceClassJarProvider",
  "JavaInfo",
  "AndroidNativeLibsInfo",
  "ProguardSpecProvider",
  "AndroidIdeInfo",
  "FileProvider",
  "FilesToRunProvider",
  "OutputGroupInfo",
]

@katre katre changed the title pre-alpha manifest merger skips manifests Starlark aar_import does not expose StarlarkAndroidResourcesInfo May 9, 2023
@katre
Copy link
Member Author

katre commented May 9, 2023

Retitled issue to clarify the root cause.

@ted-xie
Copy link
Contributor

ted-xie commented Jun 9, 2023

@ThomasCJY
Copy link

Is this issue fixed in #224?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants