xerial / sbt-jcheckstyle   0.2.1

GitHub

A sbt plugin for checking Java code styles

Scala versions: 2.12
sbt plugins: 1.x

sbt-jcheckstyle

A sbt plugin for checking Java code styles with checkstyle.

CI Maven Central

Compatibility

sbt-jcheckstyle sbt Scala (build)
0.3.x 2.x 3
0.2.x 1.x 2.12

Usage

Add sbt-jcheckstyle plugin to your project/plugins.sbt, then run the jcheckStyle task:

project/plugins.sbt

// sbt 2.x (use sbt-jcheckstyle 0.2.x for sbt 1.x)
addSbtPlugin("org.xerial.sbt" % "sbt-jcheckstyle" % "0.3.0")
# Check code style of java codes
$ sbt jcheckStyle

# Check code style of java test codes
$ sbt Test/jcheckStyle

Run style check before compilation

Add the following sbt settings:

Compile / compile := (Compile / compile).dependsOn(Compile / jcheckStyle).value
Test / compile    := (Test / compile).dependsOn(Test / jcheckStyle).value

Style configuration

To configure Java code style, edit jcheckStyleConfig setting. In default, it uses Google's Java style:

jcheckStyleConfig := "google" // or "facebook", "sun" or path to your checkstyle.xml

Here is the list of the available styles:

Or you can specify your own configuration:

jcheckStyleConfig := "checkstyle.xml"