gpt4 book ai didi

scala - sbt:在编译测试时设置特定的 scalacOptions 选项

转载 作者:行者123 更新时间:2023-12-04 00:58:10 25 4
gpt4 key购买 nike

通常我使用这组选项来编译 Scala 代码:

scalacOptions ++= Seq(
"-deprecation",
"-encoding", "UTF-8",
"-feature",
"-unchecked",
"-language:higherKinds",
"-language:implicitConversions",
"-Xfatal-warnings",
"-Xlint",
"-Yinline-warnings",
"-Yno-adapted-args",
"-Ywarn-dead-code",
"-Ywarn-numeric-widen",
"-Ywarn-value-discard",
"-Xfuture",
"-Ywarn-unused-import"
)

但是其中一些不能很好地与 ScalaTest 配合使用,所以我想禁用 -Ywarn-dead-code-Ywarn-value-discard编译测试时。

我尝试添加这样的范围
scalacOptions in Compile ++= Seq(...)

或者
scalacOptions in (Compile, compile) ++= Seq(...)

甚至
val ignoredInTestScalacOptions = Set(
"-Ywarn-dead-code",
"-Ywarn-value-discard"
)

scalacOptions in Test ~= { defaultOptions =>
defaultOptions filterNot ignoredInTestScalacOptions
}

但是前两个禁用正常编译范围的选项,而后者不影响测试编译选项。

编译测试时如何有单独的选项列表?

最佳答案

有同样的问题,@Mike Slinn 的回答对我不起作用。
我相信测试选项扩展了编译选项?
最终的诀窍是从测试中明确删除被忽略的选项
scalacOptions in Test --= Seq(
"-Ywarn-dead-code",
"-Ywarn-value-discard")

关于scala - sbt:在编译测试时设置特定的 scalacOptions 选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37630465/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com