Skip to content

Instantly share code, notes, and snippets.

@agaro1121
Created September 1, 2019 15:47
Show Gist options
  • Save agaro1121/8a898fbe699ae31254bfaa2df5aadb76 to your computer and use it in GitHub Desktop.
Save agaro1121/8a898fbe699ae31254bfaa2df5aadb76 to your computer and use it in GitHub Desktop.
[Scala]: Remove console noise
package console

import sbt._

/** [[FixScalacOptionsInConsole]] is an [[AutoPlugin]] that removes
  * noisy or unnecessary scalac options when running an sbt console.
  */
object FixScalacOptionsInConsole extends AutoPlugin {

  import Keys._

  override def requires = plugins.JvmPlugin
  override def trigger = allRequirements

  override lazy val projectSettings = Seq(
    Compile / console / scalacOptions ~= filter,
    Test / console / scalacOptions ~= filter
  )

  def filter: Seq[String] => Seq[String] =
    _ .filterNot(_ == "-feature")
      .filterNot(_.startsWith("-opt:"))
      .filterNot(_ == "-unchecked")
      .filterNot(_.startsWith("-Xlint:"))
      .filterNot(_ == "-Xfatal-warnings")
      .filterNot(_.startsWith("-Ywarn"))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment