We've been using a snippet like this one to rename the APK file generated by our Gradle build:
android.applicationVariants.all { variant ->
variant.outputs.all {
outputFileName = "${variant.name}-${variant.versionName}.apk"
}
}
Source: https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration#variant_output
I am now in the process of converting my build.gradle
to build.gradle.kts
, i. e. to the Gradle Kotlin DSL. This is one of the last missing pieces: I can't figure out how to access outputFileName
.
According to the API docs it does not even seem to exist:
BaseVariant.getOutputs()
returns aDomainObjectCollection<BaseVariantOutput>
which provides theall
method used in the snippet.BaseVariantOutput
extendsOutputFile
which extendsVariantOutput
but none of these has anoutputFileName
or any getters or setters of a matching name.
So, I suspect there is some advanced Groovy magic at work to make this work - but how do I get there in Kotlin?