4

Is it possible to run an sbt build and disable Scalastyle for just this run, using a command line argument?

I'm thinking of something similar to Checkstyle's (with Maven) -Dcheckstyle.skip=true, but cannot seem to find anything similar in the Scalastyle documentation.

Update - sbt & scalastyle config:

Scalastyle config in build.sbt:

// 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 (and 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>
Cedric Reichenbach
  • 8,970
  • 6
  • 54
  • 89
  • It would be useful if you described your sbt + scalastyle setup – laughedelic Mar 21 '18 at 20:05
  • By default, _Scalastyle_ needs to be run explicitly. It only runs as part of, say, the `test` task if you've configured it to do so. Please post the relevant settings from your _SBT_ build file... – FunctionalWannabe Mar 21 '18 at 23:18
  • Added relevant config to the question. So I'll have to manually check for command line flags in build.sbt and omit tests based on that? – Cedric Reichenbach Mar 23 '18 at 07:47

0 Answers0