oliviergauthier / gradle-appcenter-plugin

This gradle plugin allow you to upload each build variant of your android application to separate AppCenter Apps.
MIT License
85 stars 45 forks source link

Deferring evaluation of plugin extension properties such as releaseNotes until the execution phase #49

Open MichaelSims opened 4 years ago

MichaelSims commented 4 years ago

Thanks for making this excellent plugin available.

I ran into a hiccup when migrating from a previous HockeyApp plugin I was using to this one. Our project contains a custom gradle task that generates a changelog when executed and makes the text of this changelog available via a property added to the project's ext container. The changelog is ephemeral; it is generated solely for the APK upload task and is not otherwise written to a file or saved. I wanted to use this generated string as the input to your plugin extension's releaseNotes property, but setting it from this task had no effect, because the releaseNotes property on your UploadAppCenterTask is assigned from an afterEvaluate closure added when your plugin is applied (during the configuration phase). My task generates the changelog after this has occurred (during the execution phase), which is too late.

I'm far from a Gradle expert, but in the previous plugin we were using the upload task read the values directly from the project extension on-demand, during task execution, rather than baking the values in during the configuration phase. There may be an even better way to do this, but the approach of reading the extension properties on-demand seemed to work well with the other plugin.

Any thoughts on this as a potential enhancement? Thanks for your time.

(FWIW, as a workaround for now we are using File.createTempFile during the configuration phase and assigning the result to the extension property, then writing to that file during the execution phase. This works fine but has the minor cost of unconditionally creating a temp file during every configuration, even if the upload tasks won't be invoked.)