如何通过sbt编译抑制警告

问题描述 投票:3回答:1

我目前正在从事项目,我的项目可以正常工作。但是我想在运行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
scala logging sbt suppress-warnings
1个回答
6
投票

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

您需要执行以下操作:

set logLevel in compile := Level.Error

如果要在sbt文件中设置此级别,可以通过将这一行添加到build.sbt文件中来做到这一点

logLevel := Level.Error 

此外,如果只想为compile任务指定logLevel,这将有些棘手,因为您可能还需要为相关任务设置级别。

有关更多信息,请点击此处-http://www.scala-sbt.org/release/docs/Howto-Logging.html

© www.soinside.com 2019 - 2024. All rights reserved.