ab_732
ab_732

Reputation: 3897

Use of scalastyleConfigUrl

I am very new to Scala and SBT

I am trying to set up the project with Scalastyle. All works fine when running from command line, however I can't find a way to define the option as indicated on the Scalastyle website http://www.scalastyle.org/sbt.html

I tried to add something like this in the plugins.sbt

val scalastyleConfigUrl = Some(url("http://www.scalastyle.org/scalastyle_config.xml"))

I am not sure how to validate if this is working; I would expect the scalastyle_config.xml to be downloaded at each compilation, obviously I am missing something.

Second part, I would like to automate scalastyle to run at each compilation/build. How can achieve that?

Thank you

Upvotes: 1

Views: 506

Answers (1)

Andreas Neumann
Andreas Neumann

Reputation: 10894

Scalastyle Stylesheet Download

The Stylesheet will only be downloaded once every 24 hours in the default configuration and stored in scalastyleConfigUrlCacheFile.

See documentation :

scalastyleConfigRefreshHours |  Integer |   If scalastyleConfigUrl is set, refresh it after this number of hours. Default value is 24.

Example to use remote stylesheet in compile

Setting config url in build.sbt

(scalastyleConfigUrl in Compile) := Some(url("http://www.scalastyle.org/scalastyle_config.xml"))

Run on every compile, by hand

Easy solution would be to run it by triggering it with sbt or activator

sbt scalastyle compile

Redefine compile to run scalastyle

in build.sbt

compile <<= (compile in Compile).dependsOn((scalastyle in Compile).toTask(""))

You can also override the task definition or define a custom task: http://www.scala-sbt.org/0.13.0/docs/Detailed-Topics/Tasks.html#modifying-an-existing-task

Upvotes: 4

Related Questions