From c738f23e58bcaa1cc2a920d26cabcf96d9699731 Mon Sep 17 00:00:00 2001 From: Chris Stewart Date: Tue, 6 Apr 2021 06:01:11 -0500 Subject: [PATCH] Fix build warnings that came with sbt 1.5.0 (#2857) * Fix build warnings that came with sbt 1.5.0 * Fix more deprecation warnings * Fix more warnings --- app/gui/gui.sbt | 2 +- bitcoin-s-docs/docs.sbt | 2 +- build.sbt | 30 +++++++++++++++--------------- core-test/build.sbt | 6 +++--- crypto-test/crypto-test.sbt | 6 +++--- inThisBuild.sbt | 10 +++++----- project/CommonSettings.scala | 23 +++++++++++------------ 7 files changed, 39 insertions(+), 40 deletions(-) diff --git a/app/gui/gui.sbt b/app/gui/gui.sbt index b7f07c8a61..acc457e95f 100644 --- a/app/gui/gui.sbt +++ b/app/gui/gui.sbt @@ -9,4 +9,4 @@ enablePlugins(JavaAppPackaging) publish / skip := true // Fork a new JVM for 'run' and 'test:run' to avoid JavaFX double initialization problems -fork in run := true +fork / run := true diff --git a/bitcoin-s-docs/docs.sbt b/bitcoin-s-docs/docs.sbt index d3f7d95a9b..506e790f16 100644 --- a/bitcoin-s-docs/docs.sbt +++ b/bitcoin-s-docs/docs.sbt @@ -37,4 +37,4 @@ Test / bloopGenerate := None Compile / bloopGenerate := None //https://stackoverflow.com/questions/26940253/in-sbt-how-do-you-override-scalacoptions-for-console-in-all-configurations -scalacOptions in Compile ~= (_.filterNot(s => s == "-Xfatal-warnings")) +Compile / scalacOptions ~= (_.filterNot(s => s == "-Xfatal-warnings")) diff --git a/build.sbt b/build.sbt index ebb8590bb7..2b48a4f6b7 100644 --- a/build.sbt +++ b/build.sbt @@ -2,7 +2,7 @@ import com.typesafe.sbt.SbtGit.GitKeys._ import scala.util.Properties -cancelable in Global := true +Global / cancelable := true //don't allow us to wipe all of our prod databases flywayClean / aggregate := false @@ -19,12 +19,12 @@ lazy val benchSettings: Seq[Def.SettingsDefinition] = { // .settings(benchSettings: _*) // .configs(Benchmark) List( - unmanagedSourceDirectories in Test += baseDirectory.value / "src" / "bench" / "scala", + Test / unmanagedSourceDirectories += baseDirectory.value / "src" / "bench" / "scala", testFrameworks += new TestFramework("org.scalameter.ScalaMeterFramework"), - parallelExecution in Benchmark := false, - outputStrategy in Benchmark := Some(StdoutOutput), - fork in Benchmark := true, - connectInput in Benchmark := true, + Benchmark / parallelExecution := false, + Benchmark / outputStrategy := Some(StdoutOutput), + Benchmark / fork := true, + Benchmark / connectInput := true, inConfig(Benchmark)(Defaults.testSettings) ) } @@ -48,7 +48,7 @@ lazy val crypto = crossProject(JVMPlatform, JSPlatform) libraryDependencies ++= Deps.cryptoJVM ) .jsSettings( - npmDependencies in Compile ++= Seq( + Compile / npmDependencies ++= Seq( "bcrypto" -> "5.4.0" ) ) @@ -57,7 +57,7 @@ lazy val crypto = crossProject(JVMPlatform, JSPlatform) .in(file("crypto")) lazy val cryptoJS = crypto.js - .settings(scalacOptions in Compile += { + .settings(Compile / scalacOptions += { //Added to supress all of the dead code and unused variable warnings //inside of org.bitcoins.crypto.facade which is used with scalajs //see: https://www.scala-lang.org/2021/01/12/configuring-and-suppressing-warnings.html @@ -272,7 +272,7 @@ lazy val secp256k1jni = project .settings( libraryDependencies ++= Deps.secp256k1jni, // we place lib files in this directory - unmanagedResourceDirectories in Compile += baseDirectory.value / "natives", + Compile / unmanagedResourceDirectories += baseDirectory.value / "natives", //since this is not a scala module, we have no code coverage //this also doesn't place nice with scoverage, see //https://github.com/scoverage/sbt-scoverage/issues/275 @@ -500,7 +500,7 @@ lazy val bench = project .settings( libraryDependencies ++= Deps.bench, name := "bitcoin-s-bench", - skip in publish := true + publish / skip := true ) .dependsOn(coreJVM % testAndCompile, testkit) @@ -598,16 +598,16 @@ lazy val docs = project moduleName := name.value, //removes scalajs projects from unidoc, see //https://github.com/bitcoin-s/bitcoin-s/issues/2740 - unidocProjectFilter in (ScalaUnidoc, unidoc) := { + ScalaUnidoc / unidoc / unidocProjectFilter := { inAnyProject -- inProjects(jsProjects: _*) }, - target in (ScalaUnidoc, unidoc) := (baseDirectory in LocalRootProject).value / "website" / "static" / "api", - cleanFiles += (target in (ScalaUnidoc, unidoc)).value, + ScalaUnidoc / unidoc / target := (LocalRootProject / baseDirectory).value / "website" / "static" / "api", + cleanFiles += (ScalaUnidoc / unidoc / target).value, docusaurusCreateSite := docusaurusCreateSite - .dependsOn(unidoc in Compile) + .dependsOn(Compile / unidoc) .value, docusaurusPublishGhpages := docusaurusPublishGhpages - .dependsOn(unidoc in Compile) + .dependsOn(Compile / unidoc) .value ) .enablePlugins(MdocPlugin, diff --git a/core-test/build.sbt b/core-test/build.sbt index aaf2d62bb1..d15ce7063b 100644 --- a/core-test/build.sbt +++ b/core-test/build.sbt @@ -1,8 +1,8 @@ publishArtifact := false -testOptions in Test += Tests.Argument(TestFrameworks.ScalaCheck, - "-verbosity", - "2") +Test / testOptions += Tests.Argument(TestFrameworks.ScalaCheck, + "-verbosity", + "2") coverageExcludedPackages := ".*gen" diff --git a/crypto-test/crypto-test.sbt b/crypto-test/crypto-test.sbt index aaf2d62bb1..d15ce7063b 100644 --- a/crypto-test/crypto-test.sbt +++ b/crypto-test/crypto-test.sbt @@ -1,8 +1,8 @@ publishArtifact := false -testOptions in Test += Tests.Argument(TestFrameworks.ScalaCheck, - "-verbosity", - "2") +Test / testOptions += Tests.Argument(TestFrameworks.ScalaCheck, + "-verbosity", + "2") coverageExcludedPackages := ".*gen" diff --git a/inThisBuild.sbt b/inThisBuild.sbt index 071253b987..80b03f2d5b 100644 --- a/inThisBuild.sbt +++ b/inThisBuild.sbt @@ -5,15 +5,15 @@ import scala.util.Properties val scala2_12 = "2.12.12" val scala2_13 = "2.13.5" -scalafmtOnCompile in ThisBuild := !Properties.envOrNone("CI").contains("true") +ThisBuild / scalafmtOnCompile := !Properties.envOrNone("CI").contains("true") -scalaVersion in ThisBuild := scala2_13 +ThisBuild / scalaVersion := scala2_13 -crossScalaVersions in ThisBuild := List(scala2_13, scala2_12) +ThisBuild / crossScalaVersions := List(scala2_13, scala2_12) //https://github.com/sbt/sbt/pull/5153 //https://github.com/bitcoin-s/bitcoin-s/pull/2194 -excludeLintKeys in Global ++= Set( +Global / excludeLintKeys ++= Set( com.typesafe.sbt.packager.Keys.maintainer, Keys.mainClass, com.typesafe.sbt.SbtGit.GitKeys.gitRemoteRepo @@ -22,4 +22,4 @@ excludeLintKeys in Global ++= Set( //needed so that we can use our versions with docker //see: https://github.com/dwijnand/sbt-dynver#portable-version-strings //https://github.com/bitcoin-s/bitcoin-s/issues/2672 -dynverSeparator in ThisBuild := "-" +ThisBuild / dynverSeparator := "-" diff --git a/project/CommonSettings.scala b/project/CommonSettings.scala index 8f450fe3cf..cd71af781e 100644 --- a/project/CommonSettings.scala +++ b/project/CommonSettings.scala @@ -38,23 +38,22 @@ object CommonSettings { url("https://twitter.com/Chris_Stewart_5") ) ), - scalacOptions in Compile ++= compilerOpts(scalaVersion = - scalaVersion.value), + Compile / scalacOptions ++= compilerOpts(scalaVersion = scalaVersion.value), Test / scalacOptions ++= testCompilerOpts(scalaVersion = scalaVersion.value), //remove annoying import unused things in the scala console //https://stackoverflow.com/questions/26940253/in-sbt-how-do-you-override-scalacoptions-for-console-in-all-configurations - scalacOptions in (Compile, console) ~= (_ filterNot (s => + Compile / console / scalacOptions ~= (_ filterNot (s => s == "-Ywarn-unused-import" || s == "-Ywarn-unused" || s == "-Xfatal-warnings" //for 2.13 -- they use different compiler opts || s == "-Xlint:unused")), //we don't want -Xfatal-warnings for publishing with publish/publishLocal either - scalacOptions in (Compile, doc) ~= (_ filterNot (s => + Compile / doc / scalacOptions ~= (_ filterNot (s => s == "-Xfatal-warnings")), - scalacOptions in (Test, console) ++= (scalacOptions in (Compile, console)).value, - scalacOptions in Test ++= testCompilerOpts(scalaVersion.value), + Test / console / scalacOptions ++= (Compile / console / scalacOptions).value, + Test / scalacOptions ++= testCompilerOpts(scalaVersion.value), licenses += ("MIT", url("http://opensource.org/licenses/MIT")) ) @@ -148,9 +147,9 @@ object CommonSettings { lazy val testSettings: Seq[Setting[_]] = Seq( //show full stack trace (-oF) of failed tests and duration of tests (-oD) - testOptions in Test += Tests.Argument(TestFrameworks.ScalaTest, "-oDF"), - logBuffered in Test := false, - skip.in(publish) := true + Test / testOptions += Tests.Argument(TestFrameworks.ScalaTest, "-oDF"), + Test / logBuffered := false, + skip / publish := true ) ++ settings lazy val prodSettings: Seq[Setting[_]] = settings @@ -168,9 +167,9 @@ object CommonSettings { //set the user to be 'bitcoin-s' rather than //the default provided by sbt native packager //which is 'demiourgos728' - daemonUser in Docker := "bitcoin-s", - packageName in Docker := packageName.value, - version in Docker := version.value, + Docker / daemonUser := "bitcoin-s", + Docker / packageName := packageName.value, + Docker / version := version.value, dockerUpdateLatest := isSnapshot.value ) }