运行 scalafmtCheck 在 sbt 程序集中

Run scalafmtCheck in an sbt assembly

我想 运行 scalafmtCheck sbt assembly。我尝试添加:

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

我遇到了那个错误:

[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]

有什么想法吗?

你快到了。 scalafmtCheck 也是一项任务,因此需要范围。您需要做的是:

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

如果你想把它添加到组装阶段,你可以这样做:

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

如果您希望格式也将此应用于您的测试,您可以这样做:

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

或仅在组装阶段:

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