I'm working on an Android app and utilizing baseline profiles with the new Gradle plugin and GMD, as outlined in the docs. My app requires the BaselineProfileGenerator class to run on a pre-populated database with mock data, which I manage using a demo build type in my Gradle configuration:
buildTypes {
getByName("release") {
isMinifyEnabled = true
// ... other configurations ...
}
register("demo") {
initWith(getByName("release"))
matchingFallbacks.add("release")
// ... other configurations ...
}
}
Using the generateDemoBaselineProfile
Gradle task, I can generate the baseline-prof.txt
file in app/src/demo/generated/baselineProfiles/
. However, I currently have to manually copy this file to app/src/main/baselineProfiles/
so that the release build can make use of it.
The Problem: I want to automate this process using automaticGenerationDuringBuild = true
, but I'm facing challenges. Ideally, I'd like to use the mergeIntoMain = true
setting:
baselineProfile {
saveInSrc = true
mergeIntoMain = true
automaticGenerationDuringBuild = true
}
With this, I can run generateBaselineProfile
and everything should get merged into one baseline profile in app/src/main/generated/baselineProfiles/
. The problem with this is that non-demo baselineProfile generation tasks like generateReleaseBaselineProfile
are triggered as well and fail quickly because BaselineProfileGenerator
can't do its job without the prepopulated data provided only in that demo
build type. The solution would be to somehow disable these other gradle tasks and make sure only generateDemoBaselineProfile
gets triggered when I run generateBaselineProfile
.
Perhaps an even more elegant way of solving this would be to generateDemoBaselineProfile
on automaticGenerationDuringBuild = true
and force it to copy baseline-prof.txt
to app/src/main/generated/baselineProfiles/
.
I have no idea how to do either of these things. Any help would be greatly appreciated.