Resource linking for android_library targets is unnecessary.#11294
Resource linking for android_library targets is unnecessary.#11294jongerrish wants to merge 1 commit intobazelbuild:masterfrom
Conversation
Use R.txt from AndroidCompiledResourceMerger Don't include R.java in srcjar output Avoid AndroidResourceLink action Avoid large library.ap_ + resource.srcjar outputs Enable with the following flags:- --nolink_library_resources --experimental_use_rtxt_from_merged_resources
|
Goes some way to addressing bazelbuild/rules_android#10 |
|
Thanks for reminding me about Jon: overall I like the idea of pruning things from the build, but I think this disables a useful validation step. In particular the "aapt2 link" verifies that resources referenced from XML are defined. So trying to build Is that still true after this change? I was planning on writing a new validator (potentially emitting a warning if a referenced resource is not in a direct dep) but haven't gotten to it. |
No, I don't think it's required for this. |
|
@donaldchai, since this is behind a flag which defaults to building linking the resources, that seems fine? |
Sure, but this decision is ultimately about how code is merged and how flags interact. I have no authority here. All of my own changes require approval by someone from the Bazel team, or others CCed to this PR. |
|
@jin can you merge this? |
|
@jin any objections? |
|
@donaldchai - with this flag enabled you won't get any validation from linking as its disabled. Probably this validation should happen in |
|
Hi @jin - the PR has been outstanding for a while now, is there any concern with it? I'm happy to discuss and address any issue you may have. |
|
|
||
| if (AndroidResources.definesAndroidResources(attributes)) { | ||
| implicitOutputs.add( | ||
| AndroidRuleClasses.ANDROID_JAVA_SOURCE_JAR, |
There was a problem hiding this comment.
Removing this will break any current usage of the .srcjar output as a label, whether the flag is on or off, so it looks like we'd need to go through the incompatible change process. Unfortunately there's no way to conditionally register implicit outputs based on configuration. Glancing through the code, it should be technically possible to enable that, but we'd need to think through that separately. The next best thing is to leave this here, and when --link_library_resources is false, register a FailAction for that output. This means that the failure won't be surfaced until execution time, unfortunately.
I feel the opposite way, i.e. As as a side note, detection and reporting of "resource conflicts" on |
|
Time for a decision. Are we going to merge it or not? |
|
@ahumesky could you make a call here about merging the PRs modifying Android native rules? |
|
Any updates on this? |
|
Friendly ping to all. |
|
Given the Starlarkification of the rules, this PR probably should be reopened against https://github.com/bazelbuild/rules_android at one point. I am going to close the PR, feel free to re-open if you disagree. |
Use R.txt from AndroidCompiledResourceMerger
Don't include R.java in srcjar output
Avoid AndroidResourceLink action
Avoid large library.ap_ + resource.srcjar outputs
Enable with the following flags:-
--nolink_library_resources --experimental_use_rtxt_from_merged_resources