Skip to content

Instantly share code, notes, and snippets.

@kirked
Created August 10, 2019 16:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kirked/b6616560b62406e9ab7af5714272d2b9 to your computer and use it in GitHub Desktop.
Save kirked/b6616560b62406e9ab7af5714272d2b9 to your computer and use it in GitHub Desktop.
SBT plugin - console - relax compiler options
import sbt._
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)
// turn these off for console…
val removes = Set("-feature", "-unchecked", "-Xfatal-warnings")
val removeStarts = Set("-opt:", "-Xlint:", "-Ywarn")
def filter: Seq[String] => Seq[String] =
_.filterNot(removes contains _)
.filterNot(s => removeStarts.exists(s startsWith _))
}
@kirked
Copy link
Author

kirked commented Aug 10, 2019

Original credit for this goes to some answer to a question I just happened to run across one day on StackOverflow. Couldn't find the question again for the life of me, so I'm keeping this here for posterity, and my own ease-of-mind.

This is slightly modified from the original answer, to provide the flags & options to remove in Sets, so they can be easily modified without affecting the logic.


To use this, simply copy/pasta the code into a new Scala source file in your project/ directory. SBT will compile it and use it as a project plugin automatically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment