A sbt plugin for checking Java code styles with checkstyle.
| sbt-jcheckstyle | sbt | Scala (build) |
|---|---|---|
| 0.3.x | 2.x | 3 |
| 0.2.x | 1.x | 2.12 |
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
Add the following sbt settings:
Compile / compile := (Compile / compile).dependsOn(Compile / jcheckStyle).value
Test / compile := (Test / compile).dependsOn(Test / jcheckStyle).valueTo 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.xmlHere is the list of the available styles:
google: Google's Java Style. checkstyle.xmlfacebook: Code style used in Facebook Prestosun: Code Conventions for the Java TM Programming Language. checkstyle.xml
Or you can specify your own configuration:
jcheckStyleConfig := "checkstyle.xml"