From 8c2aef75e4002f1c42f26c99ca99be0e4937b227 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sat, 19 Oct 2019 19:14:16 -0400 Subject: [PATCH] in-source sbt-houserules --- build.sbt | 25 ++++++++------- project/HouseRulesPlugin.scala | 58 ++++++++++++++++++++++++++++++++++ project/plugins.sbt | 5 ++- 3 files changed, 76 insertions(+), 12 deletions(-) create mode 100644 project/HouseRulesPlugin.scala diff --git a/build.sbt b/build.sbt index 64621fdcd..7f938aee9 100644 --- a/build.sbt +++ b/build.sbt @@ -2,16 +2,25 @@ import Dependencies._ import Util._ import com.typesafe.tools.mima.core._, ProblemFilters._ -ThisBuild / git.baseVersion := "1.3.0" ThisBuild / version := { val old = (ThisBuild / version).value nightlyVersion match { case Some(v) => v - case _ => - if (old contains "SNAPSHOT") git.baseVersion.value + "-SNAPSHOT" - else old + case _ => old } } +ThisBuild / organization := "org.scala-sbt" +ThisBuild / bintrayPackage := "util" +ThisBuild / homepage := Some(url("https://github.com/sbt/util")) +ThisBuild / description := "Util modules for sbt" +ThisBuild / scmInfo := Some(ScmInfo(url("https://github.com/sbt/util"), "git@github.com:sbt/util.git")) +ThisBuild / licenses := List(("Apache-2.0", url("https://www.apache.org/licenses/LICENSE-2.0"))) +ThisBuild / scalafmtOnCompile := true +ThisBuild / developers := List( + Developer("harrah", "Mark Harrah", "@harrah", url("https://github.com/harrah")), + Developer("eed3si9n", "Eugene Yokota", "@eed3si9n", url("http://eed3si9n.com/")), + Developer("dwijnand", "Dale Wijnand", "@dwijnand", url("https://github.com/dwijnand")), +) def internalPath = file("internal") @@ -54,16 +63,10 @@ lazy val utilRoot: Project = (project in file(".")) utilScripted ) .settings( - inThisBuild( - Seq( - bintrayPackage := "util", - homepage := Some(url("https://github.com/sbt/util")), - description := "Util module for sbt", - scmInfo := Some(ScmInfo(url("https://github.com/sbt/util"), "git@github.com:sbt/util.git")), - )), commonSettings, name := "Util Root", publish / skip := true, + mimaPreviousArtifacts := Set.empty, customCommands ) 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 4458f9e31..1b9ab3b3f 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,4 +1,7 @@ -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("com.typesafe" % "sbt-mima-plugin" % "0.6.1") addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.0.3") addSbtPlugin("org.scala-sbt" % "sbt-contraband" % "0.4.4") addSbtPlugin("com.lightbend" % "sbt-whitesource" % "0.1.16")