scalastyle / scalastyle-sbt-plugin

scalastyle-sbt-plugin
Apache License 2.0
139 stars 52 forks source link

Setting scalastyleConfig doesnt work #42

Closed nightwolfzor closed 7 years ago

nightwolfzor commented 9 years ago

To get Scalastyle SBT to work with scalastyle IntelliJ idea plugin, the file needs to be in ./idea or ./project folders and the config file needs to be called scalastyle_config.xml (not scalastyle-config.xml).

This is really silly as you would think everything would be consistent. When trying to set sbt to use the scalastyle_config.xml in the project folder in a multi module project it doesnt work!

scalastyleConfig := file("project/scalastyle_config.xml")

in sbt;

> show scalastyleConfig
[info] reports/*:scalastyleConfig
[info]  scalastyle-config.xml
[info] report-api-common/*:scalastyleConfig
[info]  scalastyle-config.xml
[info] report-sparkjobs/*:scalastyleConfig
[info]  scalastyle-config.xml
[info] etl/*:scalastyleConfig
[info]  scalastyle-config.xml
[info] common/*:scalastyleConfig
[info]  scalastyle-config.xml
[info] root-project/*:scalastyleConfig
[info]  project/scalastyle_config.xml

This is beyond frustrating.

rklaehn commented 9 years ago

+1 . I got the same problem. Isn't there ever anything about sbt that is straightforward?

ghost commented 9 years ago

scalastyleConfig := baseDirectory.value / "project" / "scalastyle_config.xml" works for me in a single-module project.

rklaehn commented 9 years ago

The project in question is a multi-module project. I would like to have different scalastyle rules for the main modules (core, laws, macros) than for the auxillary modules (benchmarks, tests).

sush-hiray commented 9 years ago

I'm also facing a similar issue for a multi-module project.

aoki commented 9 years ago
 lazy val scalastyleSettings: Seq[Def.Setting[File]] = {
    import org.scalastyle.sbt.ScalastylePlugin.scalastyleConfig
    val ssc: Def.Initialize[File] = Def.setting {baseDirectory.value / "project" / "scalastyle_config.xml"}
    Seq(
      scalastyleConfig in Compile := ssc.value,
      scalastyleConfig in Test := ssc.value
    )
  }

add the scalastyleSettings to each projects.

if you want to use same scalastyle_config.xml, should change to the <MAIN_PROJECT>.base from the baseDirectory.value.

matthewfarwell commented 7 years ago

This is probably fixed now, via #52. Can you test it against the 0.9.0-SNAPSHOT and see if it works please?