mirror of https://github.com/sbt/sbt.git
Fix nowarn in both old & new sbt plugin styles
Fixes #6430. What is the problem? As detailed in #6430, the @nowarn annotation was not suppressing warnings, even after the first attempt to fix this in PR#6431. This first PR fixed the problem for projects using enablePlugins(SbtPlugin), but not for those using sbtPlugin := true. Why is this a valuable problem to solve? The annotation was not working as users would expect. What is this solution? I have moved the scalacOptions change from SbtPlugin.projectSettings to the scalacOptions in the JvmPlugin settings. Has this been tested? Yes, a test has been added. Also, this branch was tested successfully on the twinagle repo (https://github.com/soundcloud/twinagle/pull/224).
This commit is contained in:
parent
3ef1c5508b
commit
2e6fb3f2a5
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
lazy val root = project.in(file("."))
|
||||
.settings(
|
||||
scalaVersion := "2.12.13",
|
||||
sbtPlugin := true,
|
||||
scalacOptions ++= Seq("-Xfatal-warnings", "-Xlint")
|
||||
)
|
||||
|
|
@ -1 +1,3 @@
|
|||
> compile
|
||||
$ copy-file changes/oldSbtPlugin.sbt build.sbt
|
||||
> compile
|
||||
|
|
|
|||
Loading…
Reference in New Issue