Created
August 10, 2019 16:04
-
-
Save kirked/b6616560b62406e9ab7af5714272d2b9 to your computer and use it in GitHub Desktop.
SBT plugin - console - relax compiler options
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 _)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.