// the list of dependency must be reversed to use the right overlay order.
for (int n = mFlatLibraries.size() - 1 ; n >= 0 ; n--) {
LibraryDependency dependency = mFlatLibraries.get(n);
File assetFolder = dependency.getAssetsFolder();
if (assetFolder.isDirectory()) {
AssetSet assetSet = new AssetSet(dependency.getFolder().getName());
assetSet.addSource(assetFolder);
assetSets.add(assetSet);
}
}
}
Collection<File> mainResDirs = mDefaultSourceProvider.getAssetsDirectories();
AssetSet assetSet = new AssetSet(BuilderConstants.MAIN);
assetSet.addSources(mainResDirs);
assetSets.add(assetSet);
// the list of flavor must be reversed to use the right overlay order.
for (int n = mFlavorSourceProviders.size() - 1; n >= 0 ; n--) {
SourceProvider sourceProvider = mFlavorSourceProviders.get(n);
Collection<File> flavorResDirs = sourceProvider.getAssetsDirectories();
// we need the same of the flavor config, but it's in a different list.
// This is fine as both list are parallel collections with the same number of items.
assetSet = new AssetSet(mFlavorConfigs.get(n).getName());
assetSet.addSources(flavorResDirs);
assetSets.add(assetSet);
}
// multiflavor specific overrides flavor
if (mMultiFlavorSourceProvider != null) {
Collection<File> variantResDirs = mMultiFlavorSourceProvider.getAssetsDirectories();
assetSet = new AssetSet(getFlavorName());
assetSet.addSources(variantResDirs);
assetSets.add(assetSet);
}
// build type overrides flavors
if (mBuildTypeSourceProvider != null) {
Collection<File> typeResDirs = mBuildTypeSourceProvider.getAssetsDirectories();
assetSet = new AssetSet(mBuildType.getName());
assetSet.addSources(typeResDirs);
assetSets.add(assetSet);
}
// variant specific overrides all
if (mVariantSourceProvider != null) {
Collection<File> variantResDirs = mVariantSourceProvider.getAssetsDirectories();
assetSet = new AssetSet(getFullName());
assetSet.addSources(variantResDirs);
assetSets.add(assetSet);
}
return assetSets;
}