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

gradlew reformat takes 25 seconds even for back-to-back executions #3735

Open
vlsi opened this issue Oct 2, 2020 · 4 comments
Open

gradlew reformat takes 25 seconds even for back-to-back executions #3735

vlsi opened this issue Oct 2, 2020 · 4 comments

Comments

@vlsi
Copy link
Contributor

vlsi commented Oct 2, 2020

Build scan: https://scans.gradle.com/s/v3h4b4q56gj42/timeline

It would be nice if ./gradlew reformat was incremental.

@mernst
Copy link
Member

mernst commented Oct 2, 2020

I agree it takes too long. The problem is that it calls run-google-java-format, which itself makes multiple passes over every file. The best way for you to improve this would be to upvote or comment on google/google-java-format#5. run-google-java-format has a hard-coded list of known type annotations, and it ought to be straightforward for google-java-format to take this approach as well.

To avoid re-checking, run-google-java-format could cache the hash of each file that is correctly annotated, and avoid any work for such a file. That would address your concern. Feel free to open a pull request.

(I don't encounter this problem because I don't run ./gradlew reformat. My editor automatically runs run-google-java-format every time I save a file.)

@vlsi
Copy link
Contributor Author

vlsi commented Oct 2, 2020

A slightly different angle might be to use https://github.com/autostyle/autostyle or https://github.com/diffplug/spotless to drive the formatter. Then incremental processing will be done by Gradle.

Thanks for the pointers though.

@mernst
Copy link
Member

mernst commented Oct 2, 2020

Can autostyle and spotless call out to an external formatter? If their default formatting is wrong for type annotations (as that of google-java-format is), they would need to invoke run-google-java-format. If they can do so, that would be a worthwhile integration to write. If they cannot do so, then run-google-java-format (currently written in Python) could be re-implemented as a plugin to one of them.

(Is autostyle a hard fork of spotless? The README doesn't state the relationship between them.)

@vlsi
Copy link
Contributor Author

vlsi commented Oct 2, 2020

Can autostyle and spotless call out to an external formatter?

Most of the formatters are external. I guess run-google-java-format could be plugged.

Is autostyle a hard fork of spotless?

It is. Here's background: autostyle/autostyle#20 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants