facebook / screenshot-tests-for-android

Generate fast deterministic screenshots during Android instrumentation tests
http://facebook.github.io/screenshot-tests-for-android
Apache License 2.0
1.74k stars 229 forks source link

Add annotations for compatibility with Gradle 7.0 #283

Closed lwasyl closed 3 years ago

lwasyl commented 3 years ago

(This PR won't compile until #282 or similar is merged)

Gradle 7.0 verifies that all the task properties are either inputs or outputs (https://docs.gradle.org/current/userguide/upgrading_version_6.html#task_validation_problems_are_now_errors). From looking at the plugin code I figured all the properties are inputs, although I'm not certain this is 100% correct. For example from what I see variant: TestVariant is actually both an input and output, depending on the task, but since the property is declared on the base class it's not a straightforward change to have this accurately annotated.

I decided to just add @Input annotations everywhere because this will at least make the plugin work again. However, it's only because no task declares outputs, and so up-to-date checks are off. This is desired behavior, because Android's connected check tasks are never up-to-date themselves, so screenshot tasks never being up-to-date makes sense too. But please note this would have to be explicitly declared (e.g. with outputs.upToDateWhen { false } or by linking the up-to-date check to connected test task) if any task has an @Output declared in the future.

I verified the fix with ./gradlew validatePlugins task and by running record and verify tasks on my own project with a locally published snapshot (sample doesn't seem to work with Gradle 7 either).

Fixes #281

jgavris commented 3 years ago

@xiphirx could we get this one too to complement https://github.com/facebook/screenshot-tests-for-android/pull/282 ?

facebook-github-bot commented 3 years ago

@xiphirx has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

facebook-github-bot commented 3 years ago

@xiphirx merged this pull request in facebook/screenshot-tests-for-android@081522d74a547c80c4798fd24c5ff516872ef959.