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.

Usage

Maven Central

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

// For sbt-0.13.x and 1.0.x
addSbtPlugin("org.xerial.sbt" % "sbt-jcheckstyle" % "(version)")
# 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 in Compile <<= (compile in Compile) dependsOn (jcheckStyle in Compile)
compile in Test <<= (compile in Test) dependsOn (jcheckStyle in Test)

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"