Closed ychescale9 closed 3 years ago
Dang, thanks for the thorough investigation. The issue is that if I lazily evaluate the property, then I end up in a recursive loop because I'll be getting the value I myself set: https://github.com/Triple-T/gradle-play-publisher/blob/1a009c0c8ad036c879d4c7bf1c1c389006838e3a/play/plugin/src/main/kotlin/com/github/triplet/gradle/play/PlayPublisherPlugin.kt#L352
So the idea is to get the value of the property before I overwrite it. I'm guessing forUseAtConfigurationTime
would fix it, but that means I'll be forcing your task to run even if you don't use the auto resolution feature. What I really want is a way to get the backing value of the property.
TL;DR: need to investigate the proper solution.
Yeah I've definitely run into this kind of chicken and egg problems a lot with task wiring in the lazy configuration era. I wish I could be of more help but right now I need to learn more about how the tasks are all wired up etc.
Here's the custom plugin I wrote that doesn't play well with with GPP. And as you said GPP is forcing the generateAppVersionInfo
task to run during configuration.
I'll do some more digging.
I gave up trying to fix the chicken and egg problem. The best I came up with is to only be broken if you use ResolutionStrategy.AUTO
which seems reasonable. If you're setting your own version code, you probably shouldn't be using ResolutionStrategy.AUTO
.
Interestingly, everything seems to work without specifying ResolutionStrategy
with 3.4.0-agp7.0
and latest AGP (7.0.0-alpha14
) 😄
Awesome! The default resolution strategy is FAIL
so basically it should work by default unless you've manually configured it to auto.
Describe the bug
The latest version of the plugin seems to break lazy task configuration by eagerly evaluating the
versionCode
during configuration.This breaks projects which have migrated to setting
versionCode
with the newonVariantProperties
API instead of setting it directly indefaultConfig
, as theversionCode
won't be available for querying during configuration.How To Reproduce
Instead of setting versionCode directly in defaultConfig:
Set the
versionCode
lazily as shown in this AGP recipe.Running
./gradlew help
will fails with something like:where
version_code.txt
is the@OutputFile
of the custom task which is wired up with theversionCode
property of theVariantOutput
.Versions
Is it possible to avoid evaluating the versionCodes during configuration? Maybe something along this line?
Thanks!