4

是否可以使用命令行参数运行 sbt 构建并为此运行禁用 Scalastyle?

我正在考虑类似于 Checkstyle's (with Maven) 的东西-Dcheckstyle.skip=true,但似乎在 Scalastyle 文档中找不到类似的东西。

更新 - sbt & scalastyle 配置:

build.sbt 中的 Scalastyle 配置:

// add scalastyle to compile task
lazy val compileScalastyle = taskKey[Unit]("compileScalastyle")
compileScalastyle := scalastyle.in(Compile).toTask("").value
(compile in Compile) := ((compile in Compile) dependsOn compileScalastyle).value

// add scalastyle to test task
lazy val testScalastyle = taskKey[Unit]("testScalastyle")
testScalastyle := scalastyle.in(Test).toTask("").value
(test in Test) := ((test in Test) dependsOn testScalastyle).value

(scalastyleConfig in Test) := baseDirectory.value / "scalastyle-test-config.xml"

scalastyle-config.xml(和 scalastyle-test-config.xml):

<?xml version="1.0" standalone="no" ?>
<!DOCTYPE scalastyle [
    <!ENTITY baseRules SYSTEM "scalastyle-base-rules.xml">
    ]>
<scalastyle>
    <name>Scalastyle standard configuration</name>

    <!-- <check> elements, omitted for brevity -->

</scalastyle>
4

0 回答 0