key*_*int 3 scala sbt scalastyle
我正在对我的代码空间执行scalastyle检查,参考http://www.scalastyle.org/sbt.html.
在build.sbt中:
// scalastyle check
lazy val compileScalastyle = taskKey[Unit]("compileScalastyle")
compileScalastyle := org.scalastyle.sbt.ScalastylePlugin.scalastyle.in(Compile).toTask("").value
(compile in Compile) <<= (compile in Compile) dependsOn compileScalastyle
Run Code Online (Sandbox Code Playgroud)
在project/plugins.sbt中:
addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "0.8.0")
Run Code Online (Sandbox Code Playgroud)
当我运行时sbt compile,scalastyle正在生成[warning] ***./utils/ConfigManager.scala: File must end with newline character,但编译仍然成功.
有没有办法让sbt compile scalastyle警告失败?
我只是改变这一切<check level="warning" ...>是<check level="error" ...>在scalastyleGenerateConfig,我不知道这是做正确的方式.
非常感谢
Mic*_*jac 11
我真的只能想到两个简单的选择.
显而易见的是更改scalastyle配置,以便您希望导致构建失败的警告是错误.这就是scalastyle配置的真正含义.如果您希望将某些内容视为错误,请将其命名为一个!<check level="error" ...>会给你最少的头痛.
否则,在sbt中提升警告警告的唯一简单方法是使用-Xfatal-warnings标志:
scalacOptions ++= Seq("-Xfatal-warnings")
Run Code Online (Sandbox Code Playgroud)
但是,这会将项目中的所有警告转换为错误,scalastyle与否.