An open API service indexing awesome lists of open source software.

https://github.com/autostyle/autostyle

Automatic code formatter for Gradle
https://github.com/autostyle/autostyle

automatic code-formatter gradle-plugin

Last synced: 15 days ago
JSON representation

Automatic code formatter for Gradle

Awesome Lists containing this project

README

          

# Autostyle: fix code style automatically

[![CI Status](https://github.com/autostyle/autostyle/workflows/CI/badge.svg)](https://github.com/autostyle/autostyle/actions)

Autostyle can format <java | kotlin | scala | sql | groovy | javascript | flow | typeScript | css | scss | less | jsx | vue | graphql | json | yaml | markdown | license headers | anything> using <Gradle>.

- [Autostyle for Gradle 5.6+](plugin-gradle)
- [Other build systems](CONTRIBUTING.md#how-to-add-a-new-plugin-for-a-build-system)

Ideally, a code formatter can do more than just find formatting errors - it should fix them as well. Such a formatter is really just a `Function`, 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, and build-system integration). Autostyle tackles those for you so you can focus on just a simple `Function` which can compose with any of the other formatters and build tools in Autostyle' arsenal.

## Current feature matrix

| Feature / FormatterStep | [plugin-gradle](plugin-gradle/README.md) | [(Your build tool here)](CONTRIBUTING.md#how-to-add-a-new-plugin-for-a-build-system) |
| --------------------------------------------- | ------------- | --------|
| [`generic.EndWithNewlineStep`](lib/src/main/java/com/github/autostyle/generic/EndWithNewlineStep.java) | :+1: | :white_large_square: |
| [`generic.IndentStep`](lib/src/main/java/com/github/autostyle/generic/IndentStep.java) | :+1: | :white_large_square: |
| [`generic.LicenseHeaderStep`](lib/src/main/java/com/github/autostyle/generic/LicenseHeaderStep.java) | :+1: | :white_large_square: |
| [`generic.ReplaceRegexStep`](lib/src/main/java/com/github/autostyle/generic/ReplaceRegexStep.java) | :+1: | :white_large_square: |
| [`generic.ReplaceStep`](lib/src/main/java/com/github/autostyle/generic/ReplaceStep.java) | :+1: | :white_large_square: |
| [`generic.TrimTrailingWhitespaceStep`](lib/src/main/java/com/github/autostyle/generic/TrimTrailingWhitespaceStep.java) | :+1: | :white_large_square: |
| [`java.GoogleJavaFormatStep`](lib/src/main/java/com/github/autostyle/java/GoogleJavaFormatStep.java) | :+1: | :white_large_square: |
| [`java.ImportOrderStep`](lib/src/main/java/com/github/autostyle/java/ImportOrderStep.java) | :+1: | :white_large_square: |
| [`java.RemoveUnusedImportsStep`](lib/src/main/java/com/github/autostyle/java/RemoveUnusedImportsStep.java) | :+1: | :white_large_square: |
| [`kotlin.KtLintStep`](lib/src/main/java/com/github/autostyle/kotlin/KtLintStep.java) | :+1: | :white_large_square: |
| [`markdown.FreshMarkStep`](lib/src/main/java/com/github/autostyle/markdown/FreshMarkStep.java) | :+1: | :white_large_square: |
| [`npm.PrettierFormatterStep`](lib/src/main/java/com/github/autostyle/npm/PrettierFormatterStep.java) | :+1: | :white_large_square: |
| [`npm.TsFmtFormatterStep`](lib/src/main/java/com/github/autostyle/npm/TsFmtFormatterStep.java) | :+1: | :white_large_square: |
| [`scala.ScalaFmtStep`](lib/src/main/java/com/github/autostyle/scala/ScalaFmtStep.java) | :+1: | :white_large_square: |
| [`sql.DBeaverSQLFormatterStep`](lib/src/main/java/com/github/autostyle/sql/DBeaverSQLFormatterStep.java) | :+1: | :white_large_square: |
| [(Your FormatterStep here)](CONTRIBUTING.md#how-to-add-a-new-formatterstep) | :white_large_square: | :white_large_square: |
| Fast up-to-date checking | :+1: | :white_large_square: |
| Automatic idempotency safeguard | :+1: | :white_large_square: |

*Why are there empty squares?* Many projects get harder to work on as they get bigger.
Autostyle is easier to work on than ever, and one of the reasons why is that we don't require
contributors to "fill the matrix". So far Autostyle works better with Gradle, however we would consider PRs
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.

## Release signing keys

`6FF955169D698CC09BA7403AC99BFE8CD562EAC1` since 2025-07-20

## Acknowledgements
- Thanks to contributors of [Spotless](https://github.com/diffplug/spotless).
- Built by [Gradle](https://gradle.org/).
- Tested by [JUnit](https://junit.org/).
- Maintained by [Vladimir Sitnikov](https://github.com/vlsi).