-
-
Notifications
You must be signed in to change notification settings - Fork 115
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
Add intellij format workflow #110
Conversation
https://github.com/onthegomap/planetiler/actions/runs/1935264625 ℹ️ Base Logs 4c9c24f
ℹ️ This Branch Logs bab3620
|
I think it would be good to get automate formatting and linting... just wondering if it might be better to use a tool for both of those that doesn't force people to use intellij? Ideally you could run the formatter/linter from the command line, github action, or use it in a plugin in your editor of choice. Intellij's formatter seems to be tightly coupled to the full intellij installation. spotless seems to be the most popular formatter framework for java/maven. It supports a few formatter implementations, not sure which one would be the best yet:
Any thoughts here @wipfli ? |
Also on the github action, was the idea that it would format code on push, and update their fork? Or just fail if they haven't formatter? |
Thanks for sharing other options. I was hoping that you would do this. I am happy to have a closer look at these. Regarding CI formatting, I think it should just fail... |
Java friend @ZeLonewolf what is your preferred formatter? |
By the way, what is the difference between java and maven? |
@wipfli my typical practice is to use the Eclipse formatter, customized "the way I like it" so it's sane with Java 8 streams and then commit the settings file to the repository. But there are probably more modern approaches today. |
Maven is a dependency management system. Gradle uses maven behind the scenes also. Basically, you can declare your dependencies and maven pulls down the transitive dependencies. It's similar to what npm does. |
#117 shows what google-java-format would look like. |
Dug into this a bit more... Google java format intellij plugin works until you run it on a file that uses newer java features, then it fails silently... there are some workarounds but the setup is too complicated to expect any newcomer to do. Eclipse java formatter plugin seems to work OK in intellij, and from the command-line with spotless. The current intellij formatter settings are customized from Google's style guide - they have matching eclipse configuration so it wouldn't be too hard to get to identical config for that. There's also a spotless issue for supporting the intellij formatter diffplug/spotless#200 - but I don't see any path toward a resolution until intellij makes their formatter available outside the IDE installation itself. So I think our options here are:
What do you think? |
This seems reasonable to me. The goal here is to avoid the creation of unnecessary diffs when contributing PRs, and this accomplishes it with what sounds like reasonably minimal pain. |
Another plus for eclipse formatter config (and checkstyle for linting) is that they work out of the box for vscode as well: https://code.visualstudio.com/docs/java/java-linting#_applying-formatter-settings |
@wipfli I can help set this up, will aim for a diff that migrates to eclipse formatter and adds instructions for vscode, IntelliJ, and eclipse and a GitHub action to check. |
Beautiful, thanks @msbarry. I use vscode. |
And thanks for helping out with this @msbarry. I played around with maven and gradle and spotless this morning but was completely lost... |
Took a stab at migrating to eclipse formatter to support vscode, intellij, and eclipse here: #122 |
No description provided.