From 2064415f025810701055ea9d4a5117dc7f0ba123 Mon Sep 17 00:00:00 2001 From: Jakob Odersky Date: Wed, 23 Aug 2017 17:28:20 -0700 Subject: Move to sbt 1 --- build.sbt | 24 ++++----- project/build.properties | 5 +- project/plugins.sbt | 18 +++---- src/main/scala/xyz.driver.sbt/SbtSettings.scala | 66 ++++++++++++------------- version.sbt | 2 +- 5 files changed, 48 insertions(+), 67 deletions(-) diff --git a/build.sbt b/build.sbt index aba0e46..5d3bf0c 100644 --- a/build.sbt +++ b/build.sbt @@ -2,26 +2,20 @@ sbtPlugin := true organization := "xyz.driver" name := "sbt-settings" -scalaVersion := "2.10.6" +scalaVersion := "2.12.3" publishMavenStyle := true -// Code style plugins -addSbtPlugin("com.lucidchart" % "sbt-scalafmt" % "1.6") -addSbtPlugin("org.wartremover" % "sbt-wartremover" % "2.0.3") -addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "0.8.0") +addSbtPlugin("com.lucidchart" %% "sbt-scalafmt" % "1.10") +addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "1.0.0") // Launch and deploy/release plugins -addSbtPlugin("io.spray" % "sbt-revolver" % "0.8.0") -addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.6.1") -addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "0.8.5") -addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.1.5") -addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.4") -addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.3") -addSbtPlugin("se.marcuslonnberg" % "sbt-docker" % "1.4.0") - -// This plugin represents functionality that is to be added to sbt in the future -addSbtPlugin("org.scala-sbt" % "sbt-core-next" % "0.1.1") +addSbtPlugin("io.spray" %% "sbt-revolver" % "0.9.0") +addSbtPlugin("com.eed3si9n" %% "sbt-buildinfo" % "0.7.0") +addSbtPlugin("com.typesafe.sbt" %% "sbt-git" % "0.9.3") +addSbtPlugin("com.typesafe.sbt" %% "sbt-native-packager" % "1.2.2") +addSbtPlugin("com.eed3si9n" %% "sbt-assembly" % "0.14.5") +addSbtPlugin("com.github.gseitz" %% "sbt-release" % "1.0.6") publishTo := { val jfrog = "https://drivergrp.jfrog.io/drivergrp/" diff --git a/project/build.properties b/project/build.properties index 3507256..b7dd3cb 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1,4 +1 @@ -#Activator-generated Properties -#Wed Jul 06 16:08:49 PDT 2016 -template.uuid=a675a7df-bee3-48df-9eaa-688d99e5814e -sbt.version=0.13.16 +sbt.version=1.0.2 diff --git a/project/plugins.sbt b/project/plugins.sbt index f6e2ef2..6faa230 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,15 +1,9 @@ // Code style plugins - -addSbtPlugin("org.wartremover" % "sbt-wartremover" % "2.0.3") -addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "0.8.0") -addSbtPlugin("com.lucidchart" % "sbt-scalafmt" % "1.6") +addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "1.0.0") +addSbtPlugin("com.lucidchart" %% "sbt-scalafmt" % "1.10") // Launch and deploy/release plugins -addSbtPlugin("io.spray" % "sbt-revolver" % "0.8.0") -addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.6.1") -addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "0.8.5") -addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.3") -addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.3") - -// This plugin represents functionality that is to be added to sbt in the future -addSbtPlugin("org.scala-sbt" % "sbt-core-next" % "0.1.1") +addSbtPlugin("io.spray" %% "sbt-revolver" % "0.9.0") +addSbtPlugin("com.eed3si9n" %% "sbt-buildinfo" % "0.7.0") +addSbtPlugin("com.typesafe.sbt" %% "sbt-git" % "0.9.3") +addSbtPlugin("com.github.gseitz" %% "sbt-release" % "1.0.6") diff --git a/src/main/scala/xyz.driver.sbt/SbtSettings.scala b/src/main/scala/xyz.driver.sbt/SbtSettings.scala index 380e985..a044c94 100644 --- a/src/main/scala/xyz.driver.sbt/SbtSettings.scala +++ b/src/main/scala/xyz.driver.sbt/SbtSettings.scala @@ -7,19 +7,17 @@ import com.typesafe.sbt.packager.archetypes._ import com.typesafe.sbt.packager.docker.Cmd import com.typesafe.sbt.packager.docker.DockerPlugin.autoImport._ import com.typesafe.sbt.{GitBranchPrompt, GitVersioning} -import org.scalastyle.sbt.ScalastylePlugin._ +import org.scalastyle.sbt.ScalastylePlugin.autoImport._ import sbt.Keys._ import sbt.{Credentials, Project, State, _} import sbtassembly.AssemblyKeys._ import sbtassembly._ import sbtbuildinfo.BuildInfoPlugin import sbtbuildinfo.BuildInfoPlugin.autoImport.{BuildInfoKey, BuildInfoOption, _} -import sbtdocker.DockerPlugin import sbtrelease.ReleasePlugin.autoImport.ReleaseKeys._ import sbtrelease.ReleasePlugin.autoImport.ReleaseTransformations._ import sbtrelease.ReleasePlugin.autoImport._ import sbtrelease.{Version, _} -import wartremover.WartRemover.autoImport._ // we hide the existing definition for setReleaseVersion to replace it with our own import sbtrelease.ReleaseStateTransformations.{setReleaseVersion => recordReleaseVersion, inquireVersions => _} @@ -42,8 +40,14 @@ object SbtSettings extends AutoPlugin { Seq( resourceGenerators in Compile += generateScalafmtConfTask.taskValue, - scalafmt in Compile <<= (scalafmt in Compile).dependsOn(generateScalafmtConfTask), - test in scalafmt in Compile <<= (test in scalafmt in Compile).dependsOn(generateScalafmtConfTask), + scalafmt in Compile := { + generateScalafmtConfTask.value + (scalafmt in Compile).value + }, + test in scalafmt in Compile := { + generateScalafmtConfTask.value + (test in scalafmt in Compile).value + }, test in Test := { (test in scalafmt in Compile).value (test in Test).value @@ -64,30 +68,19 @@ object SbtSettings extends AutoPlugin { resourceGenerators in Compile += generateScalastyleConfTask.taskValue, scalastyleConfig := file("scalastyle-config.xml"), testScalastyle := scalastyle.in(Compile).toTask("").value, - testScalastyle in (Test, test) <<= - (testScalastyle in (Test, test)) dependsOn generateScalastyleConfTask, - testExecution in (Test, test) <<= - testExecution in (Test, test) dependsOn (generateScalastyleConfTask, testScalastyle in Compile, testScalastyle in Test) + testScalastyle in (Test, test) := { + generateScalastyleConfTask.value + (testScalastyle in (Test, test)).value + }, + testExecution in (Test, test) := { + generateScalastyleConfTask.value + (testScalastyle in Compile).value + (testScalastyle in Test).value + (testExecution in (Test, test)).value + } ) } - lazy val wartRemoverSettings = Seq( - wartremoverErrors in (Compile, compile) ++= Warts.allBut( - Wart.AsInstanceOf, - Wart.Nothing, - Wart.Overloading, - Wart.DefaultArguments, - Wart.Any, - Wart.NonUnitStatements, - Wart.Option2Iterable, - Wart.ExplicitImplicitTypes, - Wart.Throw, - Wart.ToString, - Wart.PublicInference, - Wart.ImplicitParameter, - Wart.Equals - )) - val scalacLintingSettings = Seq( scalacOptions ++= Seq( "-Xfatal-warnings", @@ -99,7 +92,7 @@ object SbtSettings extends AutoPlugin { ) ) - lazy val lintingSettings = scalacLintingSettings ++ scalastyleSettings ++ wartRemoverSettings + lazy val lintingSettings = scalacLintingSettings ++ scalastyleSettings lazy val repositoriesSettings: Seq[Setting[_]] = { Seq( @@ -143,7 +136,7 @@ object SbtSettings extends AutoPlugin { val useDefs = st.get(useDefaults).getOrElse(false) val currentV = extracted.get(version) - val releaseFunc = extracted.get(releaseVersion) + val (_, releaseFunc) = extracted.runTask(releaseVersion, st) val suggestedReleaseV = releaseFunc(currentV) // flatten the Option[Option[String]] as the get returns an Option, and the value inside is an Option @@ -181,8 +174,9 @@ object SbtSettings extends AutoPlugin { def releaseSettings(releaseProcessSteps: Seq[ReleaseStep]): Seq[Setting[_]] = { - val showReleaseVersion = settingKey[String]("the future version once releaseNextVersion has been applied to it") + val showReleaseVersion = taskKey[String]("the future version once releaseNextVersion has been applied to it") Seq( + releaseCrossBuild := true, releaseIgnoreUntrackedFiles := true, // Check http://blog.byjean.eu/2015/07/10/painless-release-with-sbt.html for details releaseVersionBump := sbtrelease.Version.Bump.Bugfix, @@ -192,7 +186,9 @@ object SbtSettings extends AutoPlugin { case ver => Version(ver).map(_.bumpBugfix.withoutQualifier.string).getOrElse(versionFormatError) }, - showReleaseVersion <<= (version, releaseVersion)((v, f) => f(v)), + showReleaseVersion := { + releaseVersion.value(version.value) + }, releaseProcess := releaseProcessSteps ) } @@ -267,7 +263,7 @@ object SbtSettings extends AutoPlugin { import com.typesafe.sbt.packager.Keys._ project - .enablePlugins(DockerPlugin, JavaAppPackaging) + .enablePlugins(JavaAppPackaging) .settings( // Settings reference http://www.scala-sbt.org/sbt-native-packager/formats/docker.html packageName in Docker := imageName, @@ -374,7 +370,7 @@ object SbtSettings extends AutoPlugin { override def projectSettings: Seq[Setting[_]] = Seq( organization := "xyz.driver", crossScalaVersions := List("2.11.11", "2.12.3"), - scalaVersion := crossScalaVersions.value.head, + scalaVersion := crossScalaVersions.value.last, scalacOptions := (scalacDefaultOptions ++ scalacLanguageFeatures), scalacOptions in (Compile, console) := (scalacDefaultOptions ++ scalacLanguageFeatures), scalacOptions in (Compile, consoleQuick) := (scalacDefaultOptions ++ scalacLanguageFeatures), @@ -383,12 +379,12 @@ object SbtSettings extends AutoPlugin { "org.scalaz" %% "scalaz-core" % "7.2.8", "com.lihaoyi" %% "acyclic" % "0.1.7" % "provided" ), - version <<= version(v => { + version := { // Sbt release versioning based on git given double -SNAPSHOT suffix // if current commit is not tagged AND there are uncommitted changes (e.g., some file is modified), // this setting fixes that, by just removing double -SNAPSHOT if it happened somehow - Option(v).map(vv => vv.replaceAll("-SNAPSHOT-SNAPSHOT", "-SNAPSHOT")).getOrElse("0.0.0") - }), + Option(version.value).map(vv => vv.replaceAll("-SNAPSHOT-SNAPSHOT", "-SNAPSHOT")).getOrElse("0.0.0") + }, fork := true ) } diff --git a/version.sbt b/version.sbt index 05d6fc9..6dc0588 100644 --- a/version.sbt +++ b/version.sbt @@ -1 +1 @@ -version in ThisBuild := "0.8.2-SNAPSHOT" +version in ThisBuild := "1.0.0-SNAPSHOT" -- cgit v1.2.3