2

I would like to run a scalafmtCheck in sbt assembly. I tried to add:

(compile in Compile) := ((compile in Compile) dependsOn scalafmtCheck).value

I got that error :

[error] References to undefined settings: 
[error] 
[error]   submissions / scalafmtCheck from submissions / Compile / compile (/home/yass/Documents/Invenis/iss/build.sbt:45)
[error]      Did you mean submissions / Compile / scalafmtCheck ?
[error] 
[error]   scalafmtCheck from Compile / compile (/home/yass/Documents/Invenis/iss/build.sbt:45)
[error]      Did you mean Compile / scalafmtCheck ?
[error]

Any idea ?

Tomer Shetah
  • 8,413
  • 7
  • 27
  • 35
Yassine
  • 123
  • 3

1 Answers1

4

You were almost there. scalafmtCheck is a task as well, therefore needs scope. What you need to do is:

Compile / compile := (Compile / compile).dependsOn(Compile / scalafmtCheck).value

If you want to add it to the assembly stage, you can do:

assembly := assembly.dependsOn(Compile / scalafmtCheck).value

If you want the format to apply this to your tests as well you can do:

Compile / compile := (Compile / compile).dependsOn(Test / scalafmtCheck).value

Or only at the assembly stage:

assembly := assembly.dependsOn(Test / scalafmtCheck).value
Tomer Shetah
  • 8,413
  • 7
  • 27
  • 35