From 8aeb43fc1189eb2aaca06d78eaa1091f94ac1f54 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sat, 19 Oct 2019 19:53:11 -0400 Subject: [PATCH 1/4] in-source sbt-houserules --- build.sbt | 60 +++++------ project/HouseRulesPlugin.scala | 58 +++++++++++ project/SbtScriptedIT.scala | 178 ++++++++++++++++----------------- project/plugins.sbt | 7 +- 4 files changed, 183 insertions(+), 120 deletions(-) create mode 100644 project/HouseRulesPlugin.scala diff --git a/build.sbt b/build.sbt index 25e1d9eab..6931c8a8e 100644 --- a/build.sbt +++ b/build.sbt @@ -7,16 +7,28 @@ val _ = { sys.props += ("line.separator" -> "\n") } -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 := "librarymanagement" +ThisBuild / homepage := Some(url("https://github.com/sbt/librarymanagement")) +ThisBuild / description := "Library management module for sbt" +ThisBuild / scmInfo := { + val slug = "sbt/librarymanagement" + Some(ScmInfo(url(s"https://github.com/$slug"), s"git@github.com:$slug.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")), +) ThisBuild / Test / classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.Flat @@ -75,24 +87,14 @@ val mimaSettings = Def settings ( lazy val lmRoot = (project in file(".")) .aggregate(lmCore, lmIvy) .settings( - inThisBuild( - Seq( - homepage := Some(url("https://github.com/sbt/librarymanagement")), - description := "Library management module for sbt", - scmInfo := { - val slug = "sbt/librarymanagement" - Some(ScmInfo(url(s"https://github.com/$slug"), s"git@github.com:$slug.git")) - }, - bintrayPackage := "librarymanagement", - ) - ), commonSettings, name := "LM Root", publish := {}, publishLocal := {}, publishArtifact in Compile := false, publishArtifact := false, - customCommands + mimaPreviousArtifacts := Set.empty, + customCommands, ) lazy val lmCore = (project in file("core")) @@ -330,19 +332,19 @@ lazy val lmIvy = (project in file("ivy")) ), ) -lazy val lmScriptedTest = (project in file("scripted-test")) - .enablePlugins(SbtPlugin) - .settings( - commonSettings, - skip in publish := true, - name := "scripted-test", - scriptedLaunchOpts := { - scriptedLaunchOpts.value ++ - Seq("-Xmx1024M", "-Dplugin.version=" + version.value) - }, - scriptedBufferLog := false - ) - .enablePlugins(SbtScriptedIT) +// lazy val lmScriptedTest = (project in file("scripted-test")) +// .enablePlugins(SbtPlugin) +// .settings( +// commonSettings, +// skip in publish := true, +// name := "scripted-test", +// scriptedLaunchOpts := { +// scriptedLaunchOpts.value ++ +// Seq("-Xmx1024M", "-Dplugin.version=" + version.value) +// }, +// scriptedBufferLog := false +// ) +// .enablePlugins(SbtScriptedIT) // we are updating the nightly process, so we are commenting this out for now // addCommandAlias("scriptedIvy", Seq( 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/SbtScriptedIT.scala b/project/SbtScriptedIT.scala index 7094191ab..d80d277b9 100644 --- a/project/SbtScriptedIT.scala +++ b/project/SbtScriptedIT.scala @@ -1,108 +1,108 @@ -import sbt._ -import Keys._ +// import sbt._ +// import Keys._ -import java.io.File -import java.util.UUID.randomUUID +// import java.io.File +// import java.util.UUID.randomUUID -object SbtScriptedIT extends AutoPlugin { +// object SbtScriptedIT extends AutoPlugin { - object autoImport { - val scriptedTestSbtRepo = settingKey[String]("SBT repository to be used in scripted tests") - val scriptedTestSbtRef = settingKey[String]("SBT branch to be used in scripted tests") - val scriptedTestLMImpl = settingKey[String]("Librarymanagement implementation to be used in scripted tests") - val scriptedSbtVersion = settingKey[String]("SBT version to be published locally for IT tests") - } +// object autoImport { +// val scriptedTestSbtRepo = settingKey[String]("SBT repository to be used in scripted tests") +// val scriptedTestSbtRef = settingKey[String]("SBT branch to be used in scripted tests") +// val scriptedTestLMImpl = settingKey[String]("Librarymanagement implementation to be used in scripted tests") +// val scriptedSbtVersion = settingKey[String]("SBT version to be published locally for IT tests") +// } - import autoImport._ - override def requires = ScriptedPlugin +// import autoImport._ +// override def requires = ScriptedPlugin - override def trigger = noTrigger +// override def trigger = noTrigger - override lazy val globalSettings = Seq( - scriptedTestSbtRepo := "https://github.com/sbt/sbt.git", - scriptedTestSbtRef := "develop", - scriptedTestLMImpl := "ivy", - scriptedSbtVersion := s"""${sbtVersion.value}-LM-SNAPSHOT""" - ) +// override lazy val globalSettings = Seq( +// scriptedTestSbtRepo := "https://github.com/sbt/sbt.git", +// scriptedTestSbtRef := "develop", +// scriptedTestLMImpl := "ivy", +// scriptedSbtVersion := s"""${sbtVersion.value}-LM-SNAPSHOT""" +// ) - private def cloneSbt(targetDir: File, repo: String, ref: String) = { - import org.eclipse.jgit.api._ +// private def cloneSbt(targetDir: File, repo: String, ref: String) = { +// import org.eclipse.jgit.api._ - if (!targetDir.exists) { - IO.createDirectory(targetDir) +// if (!targetDir.exists) { +// IO.createDirectory(targetDir) - new CloneCommand() - .setDirectory(targetDir) - .setURI(repo) - .call() +// new CloneCommand() +// .setDirectory(targetDir) +// .setURI(repo) +// .call() - val git = Git.open(targetDir) +// val git = Git.open(targetDir) - git.checkout().setName(ref).call() - } - } +// git.checkout().setName(ref).call() +// } +// } - private def publishLocalSbt( - targetDir: File, - lmVersion: String, - lmGroupID: String, - lmArtifactID: String, - version: String) = { - import sys.process._ - Process( - Seq( - "sbt", - "-J-Xms2048m", - "-J-Xmx2048m", - "-J-XX:ReservedCodeCacheSize=256m", - "-J-XX:MaxMetaspaceSize=512m", - s"""-Dsbt.build.lm.version=${lmVersion}""", - s"""-Dsbt.build.lm.organization=${lmGroupID}""", - s"""-Dsbt.build.lm.moduleName=${lmArtifactID}""", - s"""set ThisBuild / version := "${version}"""", - "clean", - "publishLocal" - ), - Some(targetDir) - ) ! - } +// private def publishLocalSbt( +// targetDir: File, +// lmVersion: String, +// lmGroupID: String, +// lmArtifactID: String, +// version: String) = { +// import sys.process._ +// Process( +// Seq( +// "sbt", +// "-J-Xms2048m", +// "-J-Xmx2048m", +// "-J-XX:ReservedCodeCacheSize=256m", +// "-J-XX:MaxMetaspaceSize=512m", +// s"""-Dsbt.build.lm.version=${lmVersion}""", +// s"""-Dsbt.build.lm.organization=${lmGroupID}""", +// s"""-Dsbt.build.lm.moduleName=${lmArtifactID}""", +// s"""set ThisBuild / version := "${version}"""", +// "clean", +// "publishLocal" +// ), +// Some(targetDir) +// ) ! +// } - private def setScriptedTestsSbtVersion(baseDir: File, version: String) = { - IO.listFiles(baseDir).foreach { d => - if (d.isDirectory) { - IO.createDirectory(d / "project") - IO.write( - d / "project" / "build.properties", - s"sbt.version=$version" - ) - } - } - } +// private def setScriptedTestsSbtVersion(baseDir: File, version: String) = { +// IO.listFiles(baseDir).foreach { d => +// if (d.isDirectory) { +// IO.createDirectory(d / "project") +// IO.write( +// d / "project" / "build.properties", +// s"sbt.version=$version" +// ) +// } +// } +// } - import sbt.ScriptedPlugin.autoImport._ +// import sbt.ScriptedPlugin.autoImport._ - override lazy val projectSettings = Seq( - scriptedTests := { - val targetDir = target.value / "sbt" +// override lazy val projectSettings = Seq( +// scriptedTests := { +// val targetDir = target.value / "sbt" - if (!targetDir.exists) { - cloneSbt(targetDir, scriptedTestSbtRepo.value, scriptedTestSbtRef.value) +// if (!targetDir.exists) { +// cloneSbt(targetDir, scriptedTestSbtRepo.value, scriptedTestSbtRef.value) - publishLocalSbt( - targetDir, - version.value, - organization.value, - s"librarymanagement-${scriptedTestLMImpl.value}", - scriptedSbtVersion.value - ) - } +// publishLocalSbt( +// targetDir, +// version.value, +// organization.value, +// s"librarymanagement-${scriptedTestLMImpl.value}", +// scriptedSbtVersion.value +// ) +// } - setScriptedTestsSbtVersion( - sbtTestDirectory.value / thisProject.value.id, - scriptedSbtVersion.value - ) +// setScriptedTestsSbtVersion( +// sbtTestDirectory.value / thisProject.value.id, +// scriptedSbtVersion.value +// ) - scriptedTests.value - } - ) -} +// scriptedTests.value +// } +// ) +// } diff --git a/project/plugins.sbt b/project/plugins.sbt index 3794c4ca6..52b4bcbbb 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,5 +1,8 @@ -addSbtPlugin("org.scala-sbt" % "sbt-houserules" % "0.3.9") -addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.0.0") +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.2") addSbtPlugin("org.scala-sbt" % "sbt-contraband" % "0.4.2") addSbtPlugin("com.lightbend" % "sbt-whitesource" % "0.1.14") From e0d2455982a9f26888fe83038226dcc00acff534 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sat, 19 Oct 2019 19:56:19 -0400 Subject: [PATCH 2/4] sbt 1.3.3 --- .travis.yml | 5 ++--- project/build.properties | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index a8a7e50e7..3a27de94e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,9 +30,8 @@ install: - unset JAVA_HOME - java -Xmx32m -version # detect sbt version from project/build.properties - # - export TRAVIS_SBT=$(grep sbt.version= project/build.properties | sed -e 's/sbt.version=//g' ) && echo "sbt $TRAVIS_SBT" - # use 1.2.8 until 1.3.0 installer is out - - export TRAVIS_SBT=1.2.8 + - export TRAVIS_SBT=$(grep sbt.version= project/build.properties | sed -e 's/sbt.version=//g' ) && echo "sbt $TRAVIS_SBT" + # - export TRAVIS_SBT=1.3.3 - sdk install sbt $TRAVIS_SBT # override Travis CI's SBT_OPTS - unset SBT_OPTS diff --git a/project/build.properties b/project/build.properties index c59667ce9..6adcdc753 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.3.0-M3 +sbt.version=1.3.3 From 6807e91edde87faa8e2be8c44b80ef3a78dfde94 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sat, 19 Oct 2019 19:59:13 -0400 Subject: [PATCH 3/4] Scala 2.12.10 --- .travis.yml | 2 +- project/Dependencies.scala | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3a27de94e..0b066459c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ group: stable language: scala scala: - - 2.12.8 + - 2.12.10 env: global: diff --git a/project/Dependencies.scala b/project/Dependencies.scala index a6cf0fdef..b46fb6c20 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -3,12 +3,12 @@ import Keys._ import sbt.contraband.ContrabandPlugin.autoImport._ object Dependencies { - val scala212 = "2.12.8" + val scala212 = "2.12.10" def nightlyVersion: Option[String] = sys.props.get("sbt.build.version") - private val ioVersion = nightlyVersion.getOrElse("1.3.0-M16") - private val utilVersion = nightlyVersion.getOrElse("1.3.0-M9") + private val ioVersion = nightlyVersion.getOrElse("1.3.1") + private val utilVersion = nightlyVersion.getOrElse("1.3.2") private val sbtIO = "org.scala-sbt" %% "io" % ioVersion From 705cb472b62b1246ed23121a58ab25dc6ae511d4 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sat, 19 Oct 2019 20:02:25 -0400 Subject: [PATCH 4/4] Add previous artifact --- build.sbt | 1 + 1 file changed, 1 insertion(+) diff --git a/build.sbt b/build.sbt index 6931c8a8e..c2037fcbc 100644 --- a/build.sbt +++ b/build.sbt @@ -77,6 +77,7 @@ val mimaSettings = Def settings ( "1.1.3", "1.1.4", "1.2.0", + "1.3.0", ) map ( version => organization.value %% moduleName.value % version