neo-sbt-scalafmt
neo-sbt-scalafmt copied to clipboard
scalafmtOnCompile doesn't work for additional confifgurations
I'm using the sbt-multi-jvm plugin which adds the MultiJvm
configuration. I have added
inConfig(MultiJvm)(scalafmtSettings)
but sources under src/multi-jvm
are not formatted on compile and also not when executing multi-ivm/scalafmt
.
Seeing something similar with the IntegrationTest
configuration in vanilla SBT. However, it:scalafmt
does work for me.
I have:
// ...
.settings(inConfig(IntegrationTest)(scalafmtSettings))
// ...
scalafmtOnCompile in ThisBuild := true
I've got a multi-module project that has sub-projects that cross-build JVM and ScalaJS, and some that are just JVM. Reformat-on-compile and issuing scalafmt don't work on the ones that are JVM+ScalaJS. Is that related to this bug?
I think the reason for this bug could be this line:
sourceDirectories := Seq(scalaSource.value)
The plugin should pick up all source directories if this is changed to sourceDirectories := unmanagedSourceDirectories.value
. There has been a similar issue in the original scalafmt sbt plugin: https://github.com/scalameta/scalafmt/pull/229 which also contains more info about unmanagedSourceDirectories
.
This should probably be changed to use sources
. Without examples, it's impossible to know if it will fix these, but I think it will be better.
I think you should not touch sourceDirectories
at all, i.e. delete the above mentioned line.
Then in lines 148 and 150 use unmanagedSourceDirectories
.