[RPBB+aapt2] android_binary assets should take precedence over those from libraries.
RELNOTES: Fixed asset precedence for android_binary rules with aapt2.
@@ -159,15 +159,18 @@ public class Aapt2ResourcePackagingAction {
.map(DependencyAndroidData::getCompiledSymbols)
.collect(toList());
+ // NB: "-A" options are in *decreasing* precedence, while "-R" options are in *increasing*
+ // precedence. While this is internally inconsistent, it matches AAPTv1's treatment of "-A".
List<Path> assetDirs =
concat(
- options.transitiveData.stream(),
- options.transitiveAssets.stream(),
+ options.primaryData.assetDirs.stream(),
+ concat(
options.directData.stream(),
- options.directAssets.stream())
- .flatMap(dep -> dep.assetDirs.stream())
+ options.directAssets.stream(),
+ options.transitiveData.stream(),
+ options.transitiveAssets.stream())
+ .flatMap(dep -> dep.assetDirs.stream()))
.collect(toList());
- assetDirs.addAll(options.primaryData.assetDirs);
final PackagedResources packagedResources =
ResourceLinker.create(aaptConfigOptions.aapt2, executorService, linkedOut)
