neo-sbt-scalafmt icon indicating copy to clipboard operation
neo-sbt-scalafmt copied to clipboard

Shared files in cross-building setup are not reformated

Open dsferruzza opened this issue 7 years ago • 1 comments

Hi!

I followed this setup for my project: http://www.scala-js.org/doc/project/cross-build.html With this, I can build for both the JVM and Scala.js, and have common source files along with target-dedicated source files.

Then I added the latest neo-sbt-scalafmt (1.14), and the following config in build.sbt:

lazy val foo = crossProject.in(file(".")).
  settings(
    scalafmtVersion in ThisBuild := "1.3.0",
    scalafmtOnCompile in ThisBuild := true,
    scalafmtTestOnCompile in ThisBuild := true,
    ignoreErrors in (ThisBuild, scalafmt) := false,
    // other settings
  ).
  jvmSettings(
    // other settings
  ).
  jsSettings(
    // other settings
  )

And here is my .scalafmt.conf file:

style = defaultWithAlign
maxColumn = 80
docstrings = JavaDoc
project.excludeFilters = [
  "build\\.sbt$"
]

When I do scalafmt in my SBT console, scalafmt runs correctly on files located in jvm/src and js/src, but not in shared/src !

Do you have any idea on how to change this behavior? (Or how to investigate more deeply what happens)

dsferruzza avatar Oct 27 '17 19:10 dsferruzza

Having the same issue, I was able to go around it by adding the shared folder to sourceDirectories:

lazy val shared = (crossProject.crossType(CrossType.Pure) in file("shared"))
  .settings(commonSettings ++ Seq(
    sourceDirectories in (Compile, scalafmt) += file("shared").getAbsoluteFile / "src" / "main" / "scala"
  ))

dribba avatar Feb 28 '18 03:02 dribba