Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help Gradle cache the verifyGoogleJavaFormat task #779

Merged

Conversation

liblit
Copy link
Contributor

@liblit liblit commented Jun 6, 2020

This works around a missing feature that has already been requested for
the Gradle google-java-format plugin:
<sherter/google-java-format-gradle-plugin#43>.
@liblit liblit added the gradle WALA’s Gradle build system label Jun 6, 2020
@liblit liblit requested a review from msridhar June 6, 2020 17:43
@liblit liblit self-assigned this Jun 6, 2020
@msridhar
Copy link
Member

msridhar commented Jun 6, 2020

I don’t really understand this change. Will the task still run again if a source file is modified?

@liblit
Copy link
Contributor Author

liblit commented Jun 6, 2020

@msridhar wrote:

I don’t really understand this change.

The standard verifyGoogleJavaFormat task is ineligible for caching because it produces no outputs. This change gives it an output, which then lets Gradle make a proper decision about whether that output is out-of-date with respect to the inputs.

Will the task still run again if a source file is modified?

Yes. Fortunately verifyGoogleJavaFormat does correctly set its inputs to the collection of all Java files in the project. If any one of those changes contents, the task will rerun.

I've checked this empirically too. Before this change, repeatedly running ./gradlew verifyGoogleJavaFormat always produced output showing that the task was being rerun:

1 actionable task: 1 executed

After this change, running that command a second time without Java changes instead prints:

1 actionable task: 1 up-to-date

However, modifying a Java file causes the next Gradle run to print:

1 actionable task: 1 executed

@liblit liblit merged commit 9dbfdf3 into wala:master Jun 6, 2020
@liblit liblit deleted the verifyGoogleJavaFormat-enable-Gradle-caching branch June 6, 2020 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gradle WALA’s Gradle build system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants