I got library which includes some resource generating. I have the task for doing generating resources:
val updateWidgetResourcesProvider = tasks.register<Copy>("updateWidgetResources") {
from("../../widget/")
include("*.png")
into("$sharedResLocation/raw")
rename { "asset_$it".replace("@", "_").toLowerCase() }
}
android.libraryVariants.all {
android.sourceSets[this.name].res.srcDirs(sharedResLocation)
mergeResourcesProvider.configure {
dependsOn(updateWidgetResourcesProvider)
}
}
When I run :myLibrary:build
everything works just perfect.
I also have an app, which uses library as dependency
dependencies {
implementation(project(":myLibrary"))
}
Problem starts when I'm building :app:build
. Task updateWidgetResourcesProvider
simply not getting executed. How do I make a resource generating task so it both executed when I'm calling :app:build
and :myLibrary:build
. Also, why myLibrary
's resource merger is not called when it is part of :app:build
task?
I would appreciate any help, also, if I could read about android gradle task tree, and why it is different when I build AAR by itself or library as part of APK/Bundle.