-
-
Notifications
You must be signed in to change notification settings - Fork 3
Description
I guess this is more of a question.. How would it be possible to customize the versionName/versionCode using data not provided as input to the lambda (GitTag, ProviderFactory, VariantInfo)?
Context: I'm building an opinionated wrapper plugin around app-versioning and would like to declare my own plugin extension that app projects populate. Those extension properties would be used in the overrideVersionName lambda to calculate the version name.
If I try to use my custom extension property in the overrideVersionName lambda like this:
class WrapperPlugin : Plugin<Project> {
override fun apply(project: Project) {
project.plugins.withType<AppPlugin> {
// exposes a "myFilter" Property<String>
val wrapperExtension: WrapperExtension = project.extensions.create(
"wrapper", WrapperExtension::class.java
)
project.plugins.apply("io.github.reactivecircus.app-versioning")
val extension = project.extensions.getByType(AppVersioningExtension::class.java)
// mapping the myFilter extension property to the app-versioning property works fine
extension.tagFilter.set(wrapperExtension.myFilter.map { "*+${it}" })
// accessing the myFilter extension property here fails
extension.overrideVersionName { gitTag, providerFactory, variantInfo ->
//do some logic based on the myFilter value
wrapperExtension.myFilter.get()
}
}
I get the error:
Property 'kotlinVersionNameCustomizer' with value '(io.github.reactivecircus.appversioning.GitTag, org.gradle.api.provider.ProviderFactory, io.github.reactivecircus.appversioning.VariantInfo) -> kotlin.String' cannot be serialized
Am I missing something obvious here?
Basically, I guess I would like "myFilter" to be a part of the input to the GenerateAppVersionInfo task.