spotless

Spotless - keep your code spotless with Gradle

License

License

The Apache Software License, Version 2.0
Categories

Categories

Gradle Build Tools
GroupId

GroupId

com.diffplug.gradle.spotless
ArtifactId

ArtifactId

spotless
Last Version

Last Version

2.4.1
Release Date

Release Date

Type

Type

jar
Description

Description

spotless
Spotless - keep your code spotless with Gradle
Project URL

Project URL

https://github.com/diffplug/spotless
Source Code Management

Source Code Management

https://github.com/diffplug/spotless

Download spotless

How to add to project

<!-- https://jarcasting.com/artifacts/com.diffplug.gradle.spotless/spotless/ -->
<dependency>
    <groupId>com.diffplug.gradle.spotless</groupId>
    <artifactId>spotless</artifactId>
    <version>2.4.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.diffplug.gradle.spotless/spotless/
implementation 'com.diffplug.gradle.spotless:spotless:2.4.1'
// https://jarcasting.com/artifacts/com.diffplug.gradle.spotless/spotless/
implementation ("com.diffplug.gradle.spotless:spotless:2.4.1")
'com.diffplug.gradle.spotless:spotless:jar:2.4.1'
<dependency org="com.diffplug.gradle.spotless" name="spotless" rev="2.4.1">
  <artifact name="spotless" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.diffplug.gradle.spotless', module='spotless', version='2.4.1')
)
libraryDependencies += "com.diffplug.gradle.spotless" % "spotless" % "2.4.1"
[com.diffplug.gradle.spotless/spotless "2.4.1"]

Dependencies

runtime (1)

Group / Artifact Type Version
org.eclipse.jgit : org.eclipse.jgit jar 4.5.0.201609210915-r

Project Modules

There are no modules declared in this project.

Spotless: Keep your code spotless

Circle CI Live chat License Apache

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 VS Code integration)

❇️ Spotless for Maven

❇️ 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 👍 👍 👍
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.LicenseHeaderStep 👍 👍 👍
generic.ReplaceRegexStep 👍 👍
generic.ReplaceStep 👍 👍
generic.TrimTrailingWhitespaceStep 👍 👍
antlr4.Antlr4FormatterStep 👍 👍
cpp.ClangFormatStep 👍
cpp.EclipseFormatterStep 👍 👍 👍
groovy.GrEclipseFormatterStep 👍 👍 👍
java.GoogleJavaFormatStep 👍 👍 👍
java.ImportOrderStep 👍 👍 👍
java.RemoveUnusedImportsStep 👍 👍 👍
java.EclipseJdtFormatterStep 👍 👍 👍
kotlin.KtLintStep 👍 👍 👍
kotlin.KtfmtStep 👍 👍
kotlin.DiktatStep 👍 👍
markdown.FreshMarkStep 👍
npm.PrettierFormatterStep 👍 👍
npm.TsFmtFormatterStep 👍 👍
python.BlackStep 👍
scala.ScalaFmtStep 👍 👍 👍
sql.DBeaverSQLFormatterStep 👍 👍 👍
wtp.EclipseWtpFormatterStep 👍 👍
(Your FormatterStep here)

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

com.diffplug.gradle.spotless

DiffPlug

View, edit, compare. Anything, from anywhere.

Versions

Version
2.4.1
2.4.0
2.3.0
2.2.0
2.1.0
2.0.0
1.3.3
1.3.2
1.3.1
1.3.0
1.2.0