sbtsbt-pluginscalastyle

Migration to sbt 1: how to run Scalastyle at compilation time


I had scalastyle running at compilation time in my project. Since I updated from sbt 0.13 to sbt 1.0.1 I don't manage to make it work again.

I followed the documentation from here and added this to my build.sbt:

lazy val compileScalaStyle: TaskKey[Unit] = taskKey[Unit]("scalastyle")

compileScalastyle := scalastyle.in(Compile).toTask("").value,
(compile in Compile) := ((compile in Compile) dependsOn compileScalastyle).value,

But I get this error: not found: value scalastyle

Do I need an import? If yes, I didn't manage to find it.


Solution

  • You should not need a special import. There seems to be a typo in compileScalaStyle. Try

    lazy val compileScalastyle = taskKey[Unit]("compileScalastyle")
    

    instead of

    lazy val compileScalaStyle: TaskKey[Unit] = taskKey[Unit]("scalastyle")
    

    Here is a working example project using Scalastyle 1.0.0 with SBT 1.0.4.