Skip to content

Suggest that sbt test depends on compile:scalastyle as well #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions sbt.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,24 @@ This has exactly the same output as the scalastyle command, except that the gene

### Running scalastyle as part of another task

You can also have your scalastyle checks automatically run as part of another task:
You can also have your scalastyle checks automatically run as part of another task.

// Create a default Scala style task to run with tests
For example, you can run scalastyle on both the main and test sources during testing, that is, running `sbt test` will also run both the `compile:scalastyle` and `test:scalastyle` tasks:

// Create default Scala style tasks to run with tests
lazy val testScalastyle = taskKey[Unit]("testScalastyle")
lazy val compileScalastyle = taskKey[Unit]("compileScalastyle")

// scalastyle >= 0.9.0
testScalastyle := scalastyle.in(Test).toTask("").value
compileScalastyle := scalastyle.in(Compile).toTask("").value
// scalastyle <= 0.8.0
testScalastyle := org.scalastyle.sbt.ScalastylePlugin.scalastyle.in(Test).toTask("").value
compileScalastyle := org.scalastyle.sbt.ScalastylePlugin.scalastyle.in(Compile).toTask("").value

(test in Test) := ((test in Test) dependsOn testScalastyle).value
(test in Test) := ((test in Test) dependsOn compileScalastyle).value


or as part of the compile task:

Expand Down