Spotless can format <antlr | c | c# | c++ | css | flow | graphql | groovy | html | java | javascript | json | jsx | kotlin | less | license headers | markdown | objective-c | protobuf | python | scala | scss | sql | typeScript | vue | yaml | anything> using <gradle | maven | anything>.
You probably want one of the links below:
βοΈ Spotless for Gradle (with integrations for VS Code and IntelliJ)
Ideally, a code formatter can do more than just find formatting errors - it should fix them as well. Such a formatter is just a Function<String, String>
, which returns a formatted version of its potentially unformatted input.
It's easy to build such a function, but there are some gotchas and lots of integration work (newlines, character encodings, idempotency, git ratcheting, and build-system integration). Spotless tackles those for you so you can focus on just a simple Function<String, String>
which can compose with any of the other formatters and build tools in Spotless' arsenal.
Feature / FormatterStep | gradle | maven | sbt | (Your build tool here) |
---|---|---|---|---|
Automatic idempotency safeguard | π | π | π | β¬ |
Misconfigured encoding safeguard | π | π | π | β¬ |
Toggle with spotless:off and spotless:on |
π | π | β¬ | β¬ |
Ratchet from origin/main or other git ref |
π | π | β¬ | β¬ |
Define line endings using git | π | π | π | β¬ |
Fast incremental format and up-to-date check | π | π | β¬ | β¬ |
Fast format on fresh checkout using buildcache | π | β¬ | β¬ | β¬ |
generic.EndWithNewlineStep |
π | π | β¬ | β¬ |
generic.IndentStep |
π | π | β¬ | β¬ |
generic.Jsr223Step |
β¬ | π | β¬ | β¬ |
generic.LicenseHeaderStep |
π | π | π | β¬ |
generic.NativeCmdStep |
π | π | β¬ | β¬ |
generic.ReplaceRegexStep |
π | π | β¬ | β¬ |
generic.ReplaceStep |
π | π | β¬ | β¬ |
generic.TrimTrailingWhitespaceStep |
π | π | β¬ | β¬ |
antlr4.Antlr4FormatterStep |
π | π | β¬ | β¬ |
cpp.ClangFormatStep |
π | β¬ | β¬ | β¬ |
cpp.EclipseFormatterStep |
π | π | π | β¬ |
groovy.GrEclipseFormatterStep |
π | π | π | β¬ |
java.GoogleJavaFormatStep |
π | π | π | β¬ |
java.ImportOrderStep |
π | π | π | β¬ |
java.PalantirJavaFormatStep |
π | π | β¬ | β¬ |
java.RemoveUnusedImportsStep |
π | π | π | β¬ |
java.EclipseJdtFormatterStep |
π | π | π | β¬ |
java.FormatAnnotationsStep |
π | π | β¬ | β¬ |
json.gson.GsonStep |
π | π | β¬ | β¬ |
json.JacksonJsonStep |
π | π | β¬ | β¬ |
json.JsonSimpleStep |
π | π | β¬ | β¬ |
kotlin.KtLintStep |
π | π | π | β¬ |
kotlin.KtfmtStep |
π | π | β¬ | β¬ |
kotlin.DiktatStep |
π | π | β¬ | β¬ |
markdown.FreshMarkStep |
π | β¬ | β¬ | β¬ |
markdown.FlexmarkStep |
β¬ | π | β¬ | β¬ |
npm.EslintFormatterStep |
π | π | β¬ | β¬ |
npm.PrettierFormatterStep |
π | π | β¬ | β¬ |
npm.TsFmtFormatterStep |
π | π | β¬ | β¬ |
pom.SortPomStep |
β¬ | π | β¬ | β¬ |
python.BlackStep |
π | β¬ | β¬ | β¬ |
scala.ScalaFmtStep |
π | π | π | β¬ |
sql.DBeaverSQLFormatterStep |
π | π | π | β¬ |
wtp.EclipseWtpFormatterStep |
π | π | β¬ | β¬ |
yaml.JacksonYamlStep |
π | π | β¬ | β¬ |
(Your FormatterStep here) | β¬ | β¬ | β¬ | β¬ |
Many projects get harder to work on as they get bigger. Spotless is easier to work on than ever, and one of the reasons why is that we don't require contributors to "fill the matrix". If you want to add Bazel support, we'd happily accept the PR even if it only supports the one formatter you use. And if you want to add FooFormatter support, we'll happily accept the PR even if it only supports the one build system you use.
Once someone has filled in one square of the formatter/build system matrix, it's easy for interested parties to fill in any empty squares, since you'll now have a working example for every piece needed.
- Thanks to Konstantin Lutovich for implementing and maintaining the maven plugin, as well as fixing remote-build cache support for Gradle.
- Thanks to Frank Vennemeyer for Groovy support via greclipse, C++ support via CDT, XML support via WTP and a huge body of work with other eclipse-based formatters.
- Thanks to Jonathan Bluett-Duncan for
- Thanks to Daz DeBoer for the reworking the guts of our gradle plugin to support buildcache, InputChanges, and lazy configuration.
- Thanks to Richard Willis for creating the VS Code extension for Spotless Gradle.
- Thanks to Ryan Gurney for creating the IntelliJ plugin for Spotless Gradle.
- Thanks to Markus Heberling for adding generic native formatters, jsr-223 formatters, and maven pom sorting.
- Thanks to Matthias Balke for adding support for Antlr.
- Thanks to Matthias Andreas Benkard for adding support for google-java-format 1.8+ (#563)
- Thanks to Thomas Broyer for adding support for google-java-format's skip-reflowing-long-strings option.
- Thanks to Ranadeep Polavarapu for adding support for ktfmt (#569)
- Thanks to Simon Gamma for adding support for npm-based formatters, twice including
prettier
andtsfmt
. - Thanks to Hakanai for adding wildcards last support to the import sorter.
- Thanks to Kevin Brooks for updating all eclipse-based formatters to 4.13 and fixing Groovy for multiproject.
- Thanks to Dylan Baroody for fixing sql formatting support for JDBI bind list params.
- Thanks to figroc for adding custom mavenCoordinate support to google-java-format.
- Thanks to Thomas Glaeser for finding and fixing a file-permissions-clobbering bug.
- Thanks to Joan Goyeau for fixing scalafmt integration.
- Thanks to Nick Sutcliffe for fixing scalafmt post-2.0.
- Thanks to Baptiste Mesta for
- porting the DBeaver formatter to Spotless, and thanks to DBeaver and its authors for their excellent SQL formatter.
- making license headers date-aware #179
- Thanks to vmdominguez and Luis Fors for adding the ability to limit formatting to specific files in gradle (#322) and maven (#392), respectively.
- Thanks to bender316 for fixing classloading on Java 9 (#426).
- Thanks to Stefan Oehme for tons of help on the internal mechanics of Gradle.
- Thanks to eyalkaspi for adding configurable date ranges to the date-aware license headers.
- Thanks to Andrew Parmet for adding ktfmt support for kotlin gradle.
- Thanks to Oliver Horn for adding AOSP support for Spotless' google-java-format integration.
- Formatting by Eclipse
- Special thanks to Mateusz Matela for huge improvements to the eclipse code formatter!
- Thanks to Zac Sweers for fixing the highly requested ktlint 0.34+ support (#469), multiple build updates and fixing a gradle deprecation warning (#434 and others).
- Thanks to Stephen Panaro for adding support for ktlint FilenameRule (#974).
- Thanks to Nelson Osacky for android doc improvements, versions bump, and a build improvement.
- Thanks to Stanley Shyiko for his help integrating ktlint.
- Thanks to Jonathan Leitschuh for adding ktlint support for Gradle Kotlin DSL files.
- Originally forked from gradle-format-plugin by Youri BonnaffΓ©.
- Thanks to IsmaΓ«l MejΓa for bumping eclipse-jdt deps to 4.11. PR #60.
- Thanks to GΓ‘bor BernΓ‘t for improvements to logging and multi-project support.
- Thanks to Oliver Szymanski for porting tsfmt and prettier to maven.
- Thanks to Andrew Oberstar for improvements to formatting java source in non-java source sets. PR #60.
- Thanks to Sameer Balasubrahmanyam for adding support for IntelliJ-style year placeholders.
- Thanks to Jamie Tanna for adding a simple JSON formatter.
- Thanks to Adib Saikali and Paul Merlin for tracking down the tricky cause of #506.
- Import ordering from EclipseCodeFormatter.
- Built by gradle.
- Tested by junit.
- Maintained by DiffPlug.