Want to take your software engineering career to the next level? Join the mailing list for career tips & advice Click here


SBT Plugin for Running Checkstyle on Java Sources

Subscribe to updates I use sbt-checkstyle-plugin

Statistics on sbt-checkstyle-plugin

Number of watchers on Github 26
Number of open issues 5
Average time to close an issue 3 days
Main language Scala
Average time to merge a PR 3 days
Open pull requests 3+
Closed pull requests 2+
Last commit over 2 years ago
Repo Created over 5 years ago
Repo Last Updated about 2 years ago
Size 101 KB
Organization / Authoretsy
Latest Release3.0.0
Page Updated
Do you use sbt-checkstyle-plugin? Leave a review!
View open issues (5)
View sbt-checkstyle-plugin activity
View on github
Fresh, new opensource launches 🚀🚀🚀
Software engineers: It's time to get promoted. Starting NOW! Subscribe to my mailing list and I will equip you with tools, tips and actionable advice to grow in your career.
Evaluating sbt-checkstyle-plugin for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)

sbt-checkstyle-plugin Build Status

This project provides an SBT 0.13+ and 1.x plugin for running Checkstyle over Java source files. For more information about Checkstyle, see http://checkstyle.sourceforge.net/

This plugin uses version 6.15 of Checkstyle.

This is a fork of the sbt-code-quality project found here.


Add the following lines to project/plugins.sbt:

addSbtPlugin("com.etsy" % "sbt-checkstyle-plugin" % "3.1.1")

sbt-checkstyle-plugin is an AutoPlugin, so there is no need to modify the build.sbt file to enable it.


You can run Checkstyle over your Java source files with the checkstyle task. You can run Checkstyle over your Java tests with the test:checkstyle task.

The Checkstyle configuration file is ./checkstyle-config.xml by default. This can be changed by setting the value of checkstyleConfigLocation. By default test:checkstyle uses the same configuration file, but this can be changed by setting the value of checkstyleConfigLocation in Test.

The Checkstyle report is output to target/checkstyle-report.xml by default. This can be changed by setting the value of checkstyleOutputFile. test:checkstyle outputs to target/checkstyle-test-report.xml, but this can be changed by setting the value of checkstyleOutputFile in Test.

To change the checkstyle configuration file set checkstyleConfigLocation in build.sbt:

checkstyleConfigLocation := CheckstyleConfigLocation.File("checkstyle-config.xml")

You can also load remote configuration files by specifying a URL:

checkstyleConfigLocation :=

Or load configuration files from the classpath by specifying a resource name:

checkstyleConfigLocation := CheckstyleConfigLocation.Classpath("com/etsy/checkstyle-config.xml")

To run Checkstyle automatically after compilation:

(checkstyle in Compile) := (checkstyle in Compile).triggeredBy(compile in Compile).value

To run Checkstyle automatically after test compilation:

(checkstyle in Test) := (checkstyle in Test).triggeredBy(compile in Test).value

XSLT transformations

The checkstyleXsltTransformations setting allows applying XSLT transformations to the XML report generated by Checkstyle. For instance, this could be used to generate a more readable HTML report. This setting takes values of Option[Set[XSLTSettings]], so multiple transformations can be applied.

You can set checkstyleXsltTransformations like so in build.sbt:

checkstyleXsltTransformations := {
  Some(Set(CheckstyleXSLTSettings(baseDirectory(_ / "checkstyle-noframes.xml").value, target(_ / "checkstyle-report.html").value)))

Failing the build

You can control what severity of issues should break the build by setting the checkstyleSeverityLevel in your build.sbt as follows:

checkstyleSeverityLevel := Some(CheckstyleSeverityLevel.Error)

Possible values are defined by the CheckstyleSeverityLevel enumeration. The default is None.

Integration tests

If you want to run Checkstyle on your integration tests add the following to your build.sbt:

lazy val root = (project in file(".")).configs(IntegrationTest)


checkstyleConfigLocation := CheckstyleConfigLocation.File("my-checkstyle-config.xml"),
checkstyle in IntegrationTest := checkstyleTask(IntegrationTest).value,
checkstyleOutputFile in IntegrationTest := target.value / "checkstyle-integration-test-report.xml"

You can then run the tasks it:checkstyle and it:checkstyle-check.

Upgrading Checkstyle version

SBT Checkstyle plugin comes with a default Checkstyle version: currently, Checkstyle 6.15 is used by default.

Provided the new Checkstyle version is compatible, you can override the version used at runtime in your project/plugins.sbt:

dependencyOverrides += "com.puppycrawl.tools" % "checkstyle" % "6.15"



  • Description: The location of the generated checkstyle report.
  • Accepts: any legal file path
  • Default: Some(target.value / "checkstyle-report.xml")


  • Description: The location of the checkstyle configuration file.
  • Accepts: CheckstyleConfigLocation.{File, URL, Classpath}
  • Default: CheckstyleConfigLocation.File("checkstyle-config.xml")


  • Description: A set of XSLT transformations to be applied to the checkstyle output (optional).
  • Accepts: Some(Set[CheckstyleXSLTSettings])
  • Default: None


  • Description: Decide how much effort to put into analysis.
  • Accepts: Some(CheckstyleSeverityLevel.{Ignore, Info, Warning, Error})
  • Default: None
sbt-checkstyle-plugin open pull requests (View All Pulls)
  • replace deprecated sbt fishbone operators
  • Cross build plugin for SBT 0.13.x & 1.0.x
  • Checkstyle output in sbt console, and configuration for build failure
sbt-checkstyle-plugin list of languages used
sbt-checkstyle-plugin latest release notes
3.0.0 Follow SBT Plugin Best Practices

Thanks to @JosephEarl sbt-checkstyle-plugin now follows the best practices guide for SBT plugins. The changes include:

  • Use autoImport, namespace all auto-imported keys and types
  • Separate Checkstyle from CheckstylePlugin to allow easier integration with other plugins
  • Add list of all settings to README
  • Rename the config sbt-tests so they all start with checkstyle-config-

The names of the setting and task keys changed in this release. Check the README for updated information on configuring and using the plugin.

2.1.0 Upgrade to Checkstyle 6.15

This release upgrades to Checkstyle 6.15.

If you would like to use a different version of Checkstyle, see the instructions here: https://github.com/etsy/sbt-checkstyle-plugin#upgrading-checkstyle-version

2.0.0 Convert to an AutoPlugin

sbt-checkstyle-plugin is now an AutoPlugin. As such there is no need to manually enable the plugin.

In addition, several breaking changes were made in this release:

  1. Move everything into the com.etsy.sbt.checkstyle package
  2. Remove the deprecated configFile setting
  3. Remove checkstyle prefix from setting names and remove the CheckstyleTasks object
  4. Match names with the Maven Checkstyle plugin when possible

The README has been updated to reflect these changes.

Other projects in Scala