mirror of https://github.com/sbt/sbt.git
Fix unused nowarn in sbt plugins
This commit is contained in:
parent
7c266e80b6
commit
56746d5792
|
|
@ -10,11 +10,22 @@ package plugins
|
|||
|
||||
import Keys._
|
||||
import Def.Setting
|
||||
import sbt.SlashSyntax0._
|
||||
import sbt.librarymanagement.Configurations.Compile
|
||||
import sbt.librarymanagement.{ SemanticSelector, VersionNumber }
|
||||
|
||||
object SbtPlugin extends AutoPlugin {
|
||||
override def requires = ScriptedPlugin
|
||||
|
||||
override lazy val projectSettings: Seq[Setting[_]] = Seq(
|
||||
sbtPlugin := true
|
||||
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
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
lazy val scala212 = "2.12.12"
|
||||
// keep this at M5 to test full version
|
||||
lazy val scala213 = "2.13.1"
|
||||
|
||||
ThisBuild / crossScalaVersions := Seq(scala212, scala213)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
lazy val root = project.in(file("."))
|
||||
.enablePlugins(SbtPlugin)
|
||||
.settings(
|
||||
scalaVersion := "2.12.13",
|
||||
scalacOptions ++= Seq("-Xfatal-warnings", "-Xlint")
|
||||
)
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package myplugin
|
||||
|
||||
import sbt._
|
||||
import sbt.Keys._
|
||||
|
||||
case object MyPlugin extends AutoPlugin {
|
||||
object autoImport {
|
||||
val helloWorld = Def.taskKey[String]("log and return hello world")
|
||||
}
|
||||
import autoImport._
|
||||
override def projectSettings: Seq[Def.Setting[_]] = Seq(
|
||||
// should not produce a "@nowarn annotation does not suppres any warnings" warning
|
||||
helloWorld := {
|
||||
streams.value.log("Hello world")
|
||||
"Hello world"
|
||||
},
|
||||
Compile / compile := {
|
||||
helloWorld.value // shoult not produce "a pure expression does nothing" warning
|
||||
(Compile / compile).value
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
> compile
|
||||
Loading…
Reference in New Issue