Open
Description
AppDistributionExtension
properties should be modelled as Property<T>
instances rather than raw values. This would allow them to be set from dependency-carrying providers, instead of requiring the values to be known at configuration time (which means the configuration cache is invalidated each time they change). Release notes which include metadata from the HEAD
commit are one use case - they'll change every time you commit or switch branch.
I can work around the issue using releaseNotesFile
and manual task dependencies:
fun Project.configureFirebaseAppDistribution(group: String) {
val outputFile = layout.buildDirectory.file("firebase-app-distribution-release-notes").get()
val generateFirebaseAppDistributionReleaseNotes = tasks.register(
"generateFirebaseAppDistributionReleaseNotes",
GenerateFirebaseAppDistributionReleaseNotesTask::class.java
) { task ->
task.outputFile.set(outputFile)
}
androidApp {
buildTypes {
debug {
extension<AppDistributionExtension> {
// UploadDistributionTask is untracked, so it will never be cached and an absolute path is fine.
releaseNotesFile = outputFile.asFile.absolutePath
groups = group
}
}
}
}
// We have to set up explicit task dependencies because the app distribution extension cannot be configured
// using dependency-carrying Providers, only raw values.
tasks.withType<UploadDistributionTask>().configureEach { task ->
task.dependsOn(generateFirebaseAppDistributionReleaseNotes)
}
}
@UntrackedTask(
because = "This task is cheap and only runs when we are uploading to Firebase App Distribution"
)
abstract class GenerateFirebaseAppDistributionReleaseNotesTask : DefaultTask() {
@get:OutputFile
abstract val outputFile: RegularFileProperty
@TaskAction fun execute() {
val latestCommitSubject = exec("git log -1 --pretty=%s")
outputFile.get().asFile.writeText(latestCommitSubject)
}
}
but I shouldn't have to - this must be a pretty common use case.