-
Notifications
You must be signed in to change notification settings - Fork 379
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spotless build integration plugin #4560
Comments
馃憤 |
The eclipse('4.8.0').configFile rootProject.file('.eclipse/format/triplea_java_eclipse_format_style.xml') |
Great, that removes that as a dealbreaker (did not try it, but looks promising). I suppose we are waiting on #4488 now to know which formatter to configure. |
Already verified it when I posted that comment--seems to work as expected. However, I had to add a blank entry to the import order file (i.e. |
@ssoloff if you'd like to submit a PR that adds the spotless config, please go for it. We can examine later when we should turn it to 'enforcing' mode to actually fail builds, in the meantime it is very valuable to have a command that would auto-fix what would otherwise be build problems. If you're short on time, let me know and I can follow-up instead. |
I found an issue with Spotless related to import ordering. Basically, Spotless sorts imports without an implicit dot ( import java.util.Collection;
import org.junit.jupiter.api.Nested;
import javafx.stage.Stage; Using Eclipse and our current import order file, those imports would remain unchanged when running Organize Imports. However, using Spotless, they get reordered as follows: import java.util.Collection;
import javafx.stage.Stage;
import org.junit.jupiter.api.Nested; One can get Spotless to follow the Eclipse order by either:
It really seems that this is a bug in Spotless because every other tool I've come across treats the import order tokens as a complete, individual package name, not simply a substring to match at the beginning of the fully-qualified package name. However, I was unable to find any open or closed issues in the Spotless tracker related to this behavior. It's possible there's some other configuration option that changes this behavior to match the IDE, but I couldn't find it. |
Another possibility to get Spotless and the IDEs to match might be to read the import order file, append a period to each non-empty value, convert the values to a list sorted by key and pass that to spotless {
importOrder spotlessImportOrderFromFile(rootProject.file('.eclipse/format/triplea.importorder'))
} where |
Do you know if Spotless has a default import order it can enforce? @ssoloff |
I removed the If I change the configuration to |
As reported in #4586 (comment), it appears the Spotless Gradle plugin automatically adds the |
Following up with spotless from format discussion: #4488 (comment)
My first impression is positive. Having a task that auto-fixes any problems detected is rad 馃憤
I did hit an error though running the eclipse format file that has an eclipse installation dependency.
For reference that was with this config:
Either of these two configs worked, and output is attached below.
Trying out google-java-format config, it seemed to have worked well and had reasonable output. I pushed a POC to: d89f394
The output looked reasonable:
Opening this ticket to talk about Spotless specifically and keep the discussion threads clean. Regardless of !4488 this looks like something we want.
The text was updated successfully, but these errors were encountered: