firebase / firebase/firebase-android-sdk

App Distribution Gradle plugin has limited configuration cache support

Open
#5,752 1 comment 1 reaction 0 assignees View on GitHub
api: appdistribution type: feature request
Dominant language
Java
Stars
2.6k
Forks
710
Avg merge
2d 23h
Merged PRs (30d)
34

Description

`AppDistributionExtension` properties should be modelled as `Property` 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 {
// 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().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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.