bazelbuild / bazel

a fast, scalable, multi-language and extensible build system
https://bazel.build
Apache License 2.0
23.13k stars 4.05k forks source link

Supporting neverlink for aar_import #13228

Open cpsauer opened 3 years ago

cpsauer commented 3 years ago

Description of the feature request:

It'd be great if aar_import would support the neverlink option, the same as in android_library.

[For context, neverlink is analogous to the (somewhat better named?) C++ option, cc_import.system_provided, and means that a library is used during compilation, but not bundled in a binary. You still do the equivalent of linking against it, but you need it to model the idea of libraries provided at runtime.]

Feature requests: what underlying problem are you trying to solve with this feature?

This would fix an issue in rules_jvm_external, where AARs from Maven break when marked as neverlink. See https://github.com/bazelbuild/rules_jvm_external/issues/535

This would also be useful for supporting building distributable libraries with Bazel, where you want to avoid bundling other libraries that should be instead pulled from Maven as dependencies.

More generally, it would support the compile-only dependency pattern, used reasonably heavily in Java-land. Presumably that's why the option was added to android_library, but I'd argue it's at least as useful to folks in aar_import.

Any other information, logs, or outputs that you want to share?

You could work around the issue by wrapping the aar_import with an android_library that has neverlink on and exports the aar_import....but neverlink itself is broken in meaningful ways. See https://github.com/bazelbuild/bazel/issues/13216. That issue would need to be fixed first to be useful in many cases, but needn't necessary block this first.

github-actions[bot] commented 1 year ago

Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 14 days unless any other activity occurs or one of the following labels is added: "not stale", "awaiting-bazeler". Please reach out to the triage team (@bazelbuild/triage) if you think this issue is still relevant or you are interested in getting the issue resolved.

cpsauer commented 1 year ago

@bazelbuild/triage, this issue still relevant and a fix would be great!

(@bazelbuild/triage doesn't seem to create a tag (no link) so I'm going to also tag @sgowroji and @Pavank1992 manually. Please coach me if you'd have preferred otherwise--and maybe update the bot's instructions)