Merge pull request #6517 from Nirvikalpa108/fix-nowarn

Fix @nowarn annotation in old sbt plugin style
This commit is contained in:
eugene yokota 2021-05-21 13:58:16 -04:00 committed by GitHub
commit 1ae2d9d59c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 14 deletions

View File

@ -959,6 +959,13 @@ object Defaults extends BuildCommon {
Vector("-Ypickle-java", "-Ypickle-write", converter.toPath(earlyOutput.value).toString) ++ old
else old
},
scalacOptions := {
val old = scalacOptions.value
if (sbtPlugin.value && VersionNumber(scalaVersion.value)
.matchesSemVer(SemanticSelector("=2.12 >=2.12.13")))
old ++ Seq("-Wconf:cat=unused-nowarn:s")
else old
},
persistJarClasspath :== true,
classpathEntryDefinesClassVF := {
(if (persistJarClasspath.value) classpathDefinesClassCache.value

View File

@ -8,24 +8,13 @@
package sbt
package plugins
import Keys._
import Def.Setting
import sbt.SlashSyntax0._
import sbt.librarymanagement.Configurations.Compile
import sbt.librarymanagement.{ SemanticSelector, VersionNumber }
import sbt.Def.Setting
import sbt.Keys._
object SbtPlugin extends AutoPlugin {
override def requires = ScriptedPlugin
override lazy val projectSettings: Seq[Setting[_]] = Seq(
sbtPlugin := true,
Compile / scalacOptions ++= {
// silence unused @nowarns in 2.12 because of https://github.com/sbt/sbt/issues/6398
// the option is only available since 2.12.13
if (VersionNumber(scalaVersion.value).matchesSemVer(SemanticSelector("=2.12 >=2.12.13")))
Some("-Wconf:cat=unused-nowarn:s")
else
None
}
sbtPlugin := true
)
}

View File

@ -0,0 +1,6 @@
lazy val root = project.in(file("."))
.settings(
scalaVersion := "2.12.13",
sbtPlugin := true,
scalacOptions ++= Seq("-Xfatal-warnings", "-Xlint")
)

View File

@ -1 +1,3 @@
> compile
$ copy-file changes/oldSbtPlugin.sbt build.sbt
> compile