scalastyle / scalastyle-sbt-plugin

scalastyle-sbt-plugin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to trigger it:scalastyle?

dvin-galstian opened this issue · comments

The integration tests in our project are in the /src/it folder and the unit tests in src/test.

Although sbt test:scalastyle works fine and checks all the files in src/test, the command sbt it:scalastyle checks the source files in src/main.

Is there a way to configure the sbt scalastyle plugin to check the files in /src/it folder?

EDIT: turns out you need to copy a little boilerplate from the plugin to get this to work (would be nice to expose this for easier use).

The following works for me:

val codeStyleIntegrationTest = taskKey[Unit]("enforce code style then integration test")

// and then in settings...
Project.inConfig(IntegrationTest)(ScalastylePlugin.rawScalastyleSettings()) ++
Seq(
  scalastyleConfig in IntegrationTest := (scalastyleConfig in scalastyle).value,
  scalastyleTarget in IntegrationTest := target.value / "scalastyle-it-results.xml",
  scalastyleFailOnError in IntegrationTest := (scalastyleFailOnError in scalastyle).value,
  (scalastyleFailOnWarning in IntegrationTest) := (scalastyleFailOnWarning in scalastyle).value,
  scalastyleSources in IntegrationTest := (unmanagedSourceDirectories in IntegrationTest).value,
  codeStyleIntegrationTest := scalastyle.in(IntegrationTest).toTask("").value,
  (test in IntegrationTest) := ((test in IntegrationTest) dependsOn codeStyleIntegrationTest).value
)