如何通过sbt编译来抑制警告

时间:2015-08-11 06:24:54

标签: scala playframework sbt

我目前正在开展项目,我的项目工作正常。但我想在运行sbt compile时禁止警告。当我运行sbt compile时,我不希望我的终端显示警告。

[warn] /Users/kumarshubham/Documents/repositories/alice/app/misc/QueryDB.scala:14: imported `QueryString' is permanently hidden by   definition of class QueryString in package misc
[warn] import misc.QueryString
[warn]             ^
[warn] /Users/kumarshubham/Documents/repositories/alice/app/misc/QueryDB.scala:26: method apply in trait WithResult is deprecated: Use   [[fold]], [[foldWhile]] or [[withResult]] instead, which manages resources and memory
[warn]       val resultSet = query().map(
[warn]                       ^
[warn] /Users/kumarshubham/Documents/repositories/alice/app/misc/QueryDB.scala:58: method apply in trait WithResult is deprecated: Use [[fold]], [[foldWhile]] or [[withResult]] instead, which manages resources and memory
[warn]       val resultSet = query().map(
[warn]                       ^
[warn] /Users/kumarshubham/Documents/repositories/alice/app/misc/QueryDB.scala:89: method apply in trait WithResult is deprecated: Use [[fold]], [[foldWhile]] or [[withResult]] instead, which manages resources and memory
[warn]       val resultSet = query().map(
[warn]                       ^
[warn] /Users/kumarshubham/Documents/repositories/alice/app/misc/QueryDB.scala:121: method apply in trait WithResult is deprecated: Use [[fold]], [[foldWhile]] or [[withResult]] instead, which manages resources and memory
[warn]         val resultSet = query().map(
[warn]                         ^
[warn] /Users/kumarshubham/Documents/repositories/alice/app/misc/QueryDB.scala:329: method apply in trait WithResult is deprecated: Use [[fold]], [[foldWhile]] or [[withResult]] instead, which manages resources and memory
[warn]       val resultSet = query().map(
[warn]                       ^
[warn] /Users/kumarshubham/Documents/repositories/alice/app/misc/QueryDB.scala:351: method apply in trait WithResult is deprecated: Use [[fold]], [[foldWhile]] or [[withResult]] instead, which manages resources and memory
[warn]       val resultSet = query().map(
[warn]                       ^
[warn] 7 warnings found

1 个答案:

答案 0 :(得分:3)

SBT 文档提供了有关如何更新整个项目或仅针对一项任务的日志记录级别的完美手册。

你需要做这样的事情:

set logLevel in compile := Level.Error

如果您想在 sbt 文件中设置此级别,可以将此行添加到 build.sbt 文件中

logLevel := Level.Error 

此外,如果您只想为编译任务指定 logLevel ,那将会有点棘手,因为您可能需要为依赖任务设置级别同样。

有关详细信息,请查看此处 - http://www.scala-sbt.org/release/docs/Howto-Logging.html