ランキングに戻る

diffplug/spotless

Java

Keep your code spotless

gradlejavaplugin-gradleformatterkotlinscalagroovymavenprettierjavascripttypescriptsql
スター成長
スター
5.6k
フォーク
543
週間成長
Issue
246
2k4k
2015年4月2019年1月2022年10月2026年7月
成果物Mavengit clone https://github.com/diffplug/spotless.git
README

Spotless: Keep your code spotless

Gradle Plugin Maven Plugin SBT Plugin

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 | shell | sql | typeScript | vue | yaml | anything> using <gradle | maven | sbt | anything>.

You probably want one of the links below:

❇️ Spotless for Gradle (with integrations for VS Code and IntelliJ)

user@machine repo % ./gradlew build
:spotlessJavaCheck FAILED
  The following files had format violations:
  src\main\java\com\diffplug\gradle\spotless\FormatExtension.java
    -\t\t····if·(targets.length·==·0)·{
    +\t\tif·(targets.length·==·0)·{
  Run './gradlew spotlessApply' to fix these violations.
user@machine repo % ./gradlew spotlessApply
:spotlessApply
BUILD SUCCESSFUL
user@machine repo % ./gradlew build
BUILD SUCCESSFUL

❇️ Spotless for Maven

user@machine repo % mvn spotless:check
[ERROR]  > The following files had format violations:
[ERROR]  src\main\java\com\diffplug\gradle\spotless\FormatExtension.java
[ERROR]    -\t\t····if·(targets.length·==·0)·{
[ERROR]    +\t\tif·(targets.length·==·0)·{
[ERROR]  Run 'mvn spotless:apply' to fix these violations.
user@machine repo % mvn spotless:apply
[INFO] BUILD SUCCESS
user@machine repo % mvn spotless:check
[INFO] BUILD SUCCESS

❇️ Spotless for SBT (external for now)

Other build systems

How it works (for potential contributors)

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.

Current feature matrix

Feature / FormatterStep gradle maven sbt (Your build tool here)
Automatic idempotency safeguard :+1: :+1: :+1: :white_large_square:
Misconfigured encoding safeguard :+1: :+1: :+1: :white_large_square:
Toggle with spotless:off and spotless:on :+1: :+1: :white_large_square: :white_large_square:
Ratchet from origin/main or other git ref :+1: :+1: :white_large_square: :white_large_square:
Define line endings using git :+1: :+1: :+1: :white_large_square:
Fast incremental format and up-to-date check :+1: :+1: :white_large_square: :white_large_square:
Fast format on fresh checkout using buildcache :+1: :white_large_square: :white_large_square: :white_large_square:
generic.EndWithNewlineStep :+1: :+1: :white_large_square: :white_large_square:
generic.IndentStep :+1: :+1: :white_large_square: :white_large_square:
generic.Jsr223Step :white_large_square: :+1: :white_large_square: :white_large_square:
generic.LicenseHeaderStep :+1: :+1: :+1: :white_large_square:
generic.NativeCmdStep :+1: :+1: :white_large_square: :white_large_square:
generic.ReplaceRegexStep :+1: :+1: :white_large_square: :white_large_square:
generic.ReplaceStep :+1: :+1: :white_large_square: :white_large_square:
generic.TrimTrailingWhitespaceStep :+1: :+1: :white_large_square: :white_large_square:
antlr4.Antlr4FormatterStep :+1: :+1: :white_large_square: :white_large_square:
biome.BiomeStep :+1: :+1: :white_large_square: :white_large_square:
cpp.ClangFormatStep :+1: :white_large_square: :white_large_square: :white_large_square:
cpp.EclipseFormatterStep :+1: :+1: :+1: :white_large_square:
go.GofmtFormatStep :+1: :white_large_square: :white_large_square: :white_large_square:
gherkin.GherkinUtilsStep :+1: :+1: :white_large_square: :white_large_square:
groovy.GrEclipseFormatterStep :+1: :+1: :+1: :white_large_square:
java.GoogleJavaFormatStep :+1: :+1: :+1: :white_large_square:
java.ImportOrderStep :+1: :+1: :+1: :white_large_square:
java.PalantirJavaFormatStep :+1: :+1: :white_large_square: :white_large_square:
java.RemoveUnusedImportsStep :+1: :+1: :+1: :white_large_square:
java.ExpandWildcardImportsStep :+1: :white_large_square: :white_large_square: :white_large_square:
java.ForbidWildcardImportsStep :+1: :+1: :+1: :white_large_square:
java.ForbidModuleImportsStep :+1: :+1: :white_large_square: :white_large_square:
java.EclipseJdtFormatterStep :+1: :+1: :+1: :white_large_square:
java.FormatAnnotationsStep :+1: :+1: :white_large_square: :white_large_square:
java.CleanthatJavaStep :+1: :+1: :white_large_square: :white_large_square:
java.TableTestFormatterStep :+1: :+1: :white_large_square: :white_large_square:
json.gson.GsonStep :+1: :+1: :white_large_square: :white_large_square:
json.JacksonJsonStep :+1: :+1: :white_large_square: :white_large_square:
json.JsonSimpleStep :+1: :+1: :white_large_square: :white_large_square:
json.JsonPatchStep :+1: :+1: :white_large_square: :white_large_square:
kotlin.KtLintStep :+1: :+1: :+1: :white_large_square:
kotlin.KtfmtStep :+1: :+1: :white_large_square: :white_large_square:
kotlin.DiktatStep :+1: :+1: :white_large_square: :white_large_square:
markdown.FreshMarkStep :+1: :white_large_square: :white_large_square: :white_large_square:
markdown.FlexmarkStep :+1: :+1: :white_large_square: :white_large_square:
npm.EslintFormatterStep :+1: :+1: :white_large_square: :white_large_square:
npm.PrettierFormatterStep :+1: :+1: :white_large_square: :white_large_square:
npm.TsFmtFormatterStep :+1: :+1: :white_large_square: :white_large_square:
pom.SortPomStep :+1: :+1: :white_large_square: :white_large_square:
protobuf.BufStep :+1: :white_large_square: :white_large_square: :white_large_square:
python.BlackStep :+1: :white_large_square: :white_large_square: :white_large_square:
rdf.RdfFormatterStep :white_large_square: :+1: :white_large_square: :white_large_square:
scala.ScalaFmtStep :+1: :+1: :+1: :white_large_square:
shell.ShfmtStep :+1: :+1: :white_large_square: :white_large_square:
sql.DBeaverSQLFormatterStep :+1: :+1: :+1: :white_large_square:
wtp.EclipseWtpFormatterStep :+1: :+1: :white_large_square: :white_large_square:
yaml.JacksonYamlStep :+1: :+1: :white_large_square: :white_large_square:
(Your FormatterStep here) :white_large_square: :white_large_square: :white_large_square: :white_large_square:

Why are there empty squares?

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.

Acknowledgements

関連リポジトリ
gradle/gradle

Adaptable, fast automation for all

GroovyApache License 2.0gradlebuild-tool
gradle.org
18.7k5.2k
GoogleContainerTools/jib

🏗 Build container images for your Java applications.

JavaMavenApache License 2.0containersdocker
14.4k1.5k
cabaletta/baritone

google maps for block game

JavaMavenGNU Lesser General Public License v3.0minecraftforgegradle
9k2k
inferjay/AndroidDevTools

收集整理Android开发所需的Android SDK、开发中用到的工具、Android开发教程、Android设计规范,免费的设计素材等。

android-sdkandroid-studio
androiddevtools.cn
8k2.1k
Meituan-Dianping/walle

Android Signature V2 Scheme签名下的新一代渠道包打包神器

JavaMavenApache License 2.0androidgradle
6.9k1.1k
igorwojda/android-showcase

💎 Android application following best practices: Kotlin, Coroutines, JetPack, Clean Architecture, Feature Modules, Tests, MVVM, DI, Static Analysis...

KotlinMIT Licensekotlinandroid
6.8k908
tuist/tuist

Your platform team, as a service

SwiftOtherxcodeswift
tuist.dev
5.7k760
mcxiaoke/packer-ng-plugin

下一代Android打包工具(对Gradle 7.x的支持,欢迎提PR)

JavaMavenApache License 2.0androidgradle
github.com/mcxiaoke
4.8k857
nisrulz/android-tips-tricks

:ballot_box_with_check: [Cheatsheet] Tips and tricks for Android Development

JavaMavenApache License 2.0android-developmentandroid-studio
nisrulz.com/android-tips-tricks/
4.7k566
Meituan-Dianping/Robust

Robust is an Android HotFix solution with high compatibility and high stability. Robust can fix bugs immediately without a reboot.

JavaMavenApache License 2.0androidhotfix
4.5k807
GradleUp/shadow

Gradle plugin to create fat/uber JARs, apply file transforms, and relocate packages for applications and libraries. Gradle version of Maven's Shade plugin.

KotlinApache License 2.0gradle-pluginhacktoberfest
gradleup.com/shadow/
4.2k426
cesarferreira/dryrun

☁️ Try the demo project of any Android Library

RubyRubyGemsMIT Licenseandroidruby
cesarferreira.com/dryrun/
3.8k276