diff --git a/build.sbt b/build.sbt index 336bf8c02..4951a8034 100644 --- a/build.sbt +++ b/build.sbt @@ -191,7 +191,7 @@ lazy val sbtRoot: Project = (project in file(".")) commands in Global += Command .single("sbtOn")((state, dir) => s"sbtProj/test:runMain sbt.RunFromSourceMain $dir" :: state), mimaSettings, - mimaPreviousArtifacts := Set() + mimaPreviousArtifacts := Set.empty, ) // This is used to configure an sbt-launcher for this version of sbt. @@ -1148,7 +1148,7 @@ def customCommands: Seq[Setting[_]] = Seq( ThisBuild / whitesourceProduct := "Lightbend Reactive Platform" ThisBuild / whitesourceAggregateProjectName := { // note this can get detached on tag build etc - val b = (ThisBuild / git.gitCurrentBranch).value + val b = sys.process.Process("git rev-parse --abbrev-ref HEAD").!! val Stable = """1\.([0-9]+)\.x""".r b match { case Stable(y) => "sbt-1." + y.toString + "-stable" diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 87c1fc71c..dd09a47df 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -10,14 +10,14 @@ object Dependencies { def nightlyVersion: Option[String] = sys.props.get("sbt.build.version") // sbt modules - private val ioVersion = nightlyVersion.getOrElse("1.3.0") - private val utilVersion = nightlyVersion.getOrElse("1.3.0") + private val ioVersion = nightlyVersion.getOrElse("1.3.1") + private val utilVersion = nightlyVersion.getOrElse("1.3.2") private val lmVersion = sys.props.get("sbt.build.lm.version") match { case Some(version) => version case _ => nightlyVersion.getOrElse("1.3.0") } - val zincVersion = nightlyVersion.getOrElse("1.3.0") + val zincVersion = nightlyVersion.getOrElse("1.3.1") private val sbtIO = "org.scala-sbt" %% "io" % ioVersion diff --git a/project/HouseRulesPlugin.scala b/project/HouseRulesPlugin.scala new file mode 100644 index 000000000..8c8958c4f --- /dev/null +++ b/project/HouseRulesPlugin.scala @@ -0,0 +1,58 @@ +import sbt._ +import Keys._ +import bintray.BintrayPlugin +import bintray.BintrayPlugin.autoImport._ + +object HouseRulesPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin && BintrayPlugin + override def trigger = allRequirements + + override def buildSettings: Seq[Def.Setting[_]] = baseBuildSettings + override def projectSettings: Seq[Def.Setting[_]] = baseSettings + + lazy val baseBuildSettings: Seq[Def.Setting[_]] = Seq( + bintrayOrganization := Some("sbt"), + bintrayRepository := "maven-releases", + ) + + lazy val baseSettings: Seq[Def.Setting[_]] = Seq( + bintrayPackage := (ThisBuild / bintrayPackage).value, + bintrayRepository := (ThisBuild / bintrayRepository).value, + scalacOptions ++= Seq("-encoding", "utf8"), + scalacOptions ++= Seq("-deprecation", "-feature", "-unchecked", "-Xlint"), + scalacOptions += "-language:higherKinds", + scalacOptions += "-language:implicitConversions", + scalacOptions ++= "-Xfuture".ifScala213OrMinus.value.toList, + scalacOptions += "-Xlint", + scalacOptions ++= "-Xfatal-warnings" + .ifScala(v => { + sys.props.get("sbt.build.fatal") match { + case Some(_) => java.lang.Boolean.getBoolean("sbt.build.fatal") + case _ => v == 12 + } + }) + .value + .toList, + scalacOptions ++= "-Yinline-warnings".ifScala211OrMinus.value.toList, + scalacOptions ++= "-Yno-adapted-args".ifScala212OrMinus.value.toList, + scalacOptions += "-Ywarn-dead-code", + scalacOptions += "-Ywarn-numeric-widen", + scalacOptions += "-Ywarn-value-discard", + scalacOptions ++= "-Ywarn-unused-import".ifScala(v => 11 <= v && v <= 12).value.toList + ) ++ Seq(Compile, Test).flatMap( + c => scalacOptions in (c, console) --= Seq("-Ywarn-unused-import", "-Xlint") + ) + + private def scalaPartV = Def setting (CrossVersion partialVersion scalaVersion.value) + + private implicit final class AnyWithIfScala[A](val __x: A) { + def ifScala(p: Long => Boolean) = + Def setting (scalaPartV.value collect { case (2, y) if p(y) => __x }) + def ifScalaLte(v: Long) = ifScala(_ <= v) + def ifScalaGte(v: Long) = ifScala(_ >= v) + def ifScala211OrMinus = ifScalaLte(11) + def ifScala211OrPlus = ifScalaGte(11) + def ifScala212OrMinus = ifScalaLte(12) + def ifScala213OrMinus = ifScalaLte(13) + } +} diff --git a/project/plugins.sbt b/project/plugins.sbt index f9dc11cb7..c5959a110 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,7 +1,8 @@ -scalaVersion := "2.12.10" scalacOptions ++= Seq("-feature", "-language:postfixOps") -addSbtPlugin("org.scala-sbt" % "sbt-houserules" % "0.3.9") +addSbtPlugin("com.dwijnand" % "sbt-dynver" % "4.0.0") +addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.5") +addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.0") addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.0.2") addSbtPlugin("org.scala-sbt" % "sbt-contraband" % "0.4.1") addSbtPlugin("de.heikoseeberger" % "sbt-header" % "3.0.2")