Status Update
Comments
xa...@google.com <xa...@google.com> #2
It looks like we implemented a really poor
task.outputs.upToDateWhen {
// Workaround for b/193244776
// Ensure the task runs if baselineFile is set and the file doesn't exist
task.projectInputs.lintOptions.inputBaselineFile.orNull?.asFile?.exists() ?: true
}
I don't think this is correct. We need to change how we handle this file. We cannot have a task read and generate this file. If we want to handle baseline file generation we need to change things.
I think an option we should look at is to generate a baseline file in the output folder when running a normal lint (this can be driven by a boolean DSL flag) and either ask people to copy it there, or simply update the updateLintBaseline
task to just copy from the output back to the location indicated in the DSL. This would make this second task much simpler (right now it's a full on lint task!) and would solve the issue of a single task both reading and generating this file.
au...@google.com <au...@google.com> #3
Any updates here? I'd love for us to drop upToDateWhen
sp...@google.com <sp...@google.com> #4
Still on the radar, but no update
sp...@google.com <sp...@google.com> #5
Now that we have the updateLintBaseline
task, we should encourage users to use it by doing the following:
Update the with instructions for running the task.lint error message Update the .lint user guide Update the .documentation on DAC Add AGP release notes about the change.
All of the above changes should be added for AGP 8.0 (no functional changes... mostly just documentation of the existing feature).
Proposed schedule for future AGP releases:
- (AGP 8.1) Warn users when they run lint with a lint baseline file set in the DSL but the file doesn't exist
- unless android.experimental.lint.missingBaselineIsEmptyBaseline=true
- (AGP 9.0) Error instead of warning
- remove lint baseline as output of lint task
Edit: removed the proposed breaking change because Change-Id: I818e5812d8a4b45a1024618ecaec399439569dfc
removed the lint baseline as an output without the need for the breaking change.
sp...@google.com <sp...@google.com> #6
Closing this bug because the baseline file is no longer an output.
Created
Description
AndroidLintTask
lists the lint baseline file (e.g.lint-baseline.xml
) as an@InputFiles
property, but the file is also functioning as an@Output
of the task, since Lint, as documentedThis isn't good practice in Gradle, and leads to some odd behavior.
For instance, if you:
gradlew app:lint -Dlint.baselines.continue=true
, generating a new baseline filegradlew app:lint -Dlint.baselines.continue=true
The baseline file is not re-created, since Gradle observes the same "before" state for both invocations and marks the task as
Up-To-Date
(Gradle doesn't include the file in the "after" snapshot for the task because the file isn't marked as an@Output
). A fix/workaround is pending for this particular issue, but there may be other issues inherent to this non-idiomatic use of the Gradle API.This comment proposes a fix in AGP for the broader issue.