Open bddckr opened 1 month ago
This might be a problem for more areas than the ProGuard mappings handling. I haven't checked whether variant information is utilized elsewhere in this plugin.
Here's a workaround to this issue that I'm successfully applying in a convention plugin. It supports the Gradle configuration cache. Note that it relies on a bunch of assumptions that work for me, but not for everyone. It's probably not easy to decide which of the potentially many outputs from a variant to pick for this. Using the first output works for my case, but it might not work for everyone else.
extensions.configure<ApplicationAndroidComponentsExtension> {
onVariants(selector().withName("release")) { variant ->
val variantNameTitleCased =
variant.name.replaceFirstChar(Char::titlecaseChar)
val applicationId = variant.applicationId
val versionName = variant.outputs[0].versionName
tasks.named<SentryUploadProguardMappingsTask>(
"uploadSentryProguardMappings$variantNameTitleCased"
) {
releaseInfo.set(
rootProject.tasks
.named("taskThatGeneratesTheVersionProperties")
.flatMap { task -> task.outputs.files.elements }
.map {
ReleaseInfo(
applicationId = applicationId.get(),
versionName = versionName.get(),
// I bake the version code into the name instead.
versionCode = null,
)
}
)
}
}
}
I worry that the task lookup might break in the future. Additionally, the task is probably not considered public API, is it? Perhaps this plugin could offer its own properties to set the various details it relies on? 🤔
Also, if someone could tell me whether I need to apply similar workarounds to other tasks, that would be much appreciated. As I said above, I'm not sure if there are other areas with similar issues.
@bddckr thanks for reporting, this actually looks like a bug on our end. In general our Gradle plugin is variant-aware, looks like we missed that part.
Gradle Version
8.10.2
AGP Version
8.7.0
Code Minifier/Optimizer
R8
Version
4.11.0
Sentry SDK Version
7.15.0
Steps to Reproduce
com.example.myproject@undefined
.The lazily configured version details should be used when uploading ProGuard mappings.
Actual Result
The statically set version values are used when uploading ProGuard mappings.