From 8a83f70fc7b307a831aa09067cdf6fcfbfdf6cbe Mon Sep 17 00:00:00 2001 From: Greg Burd Date: Wed, 25 Sep 2019 12:14:54 -0400 Subject: [PATCH] Update Scala version. --- .gitignore | 36 +++++++++++++++++ build.sbt | 79 ++++++++++++++++++++++++++++++++++---- project/Dependencies.scala | 6 +-- project/build.properties | 2 +- project/plugins.sbt | 30 ++++++++++++--- 5 files changed, 137 insertions(+), 16 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..47477f6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,36 @@ +stasis-test/original/ + +*.class +*.log + +gh-pages/ +.secrets + +idea/ + +.bloop +.metals + +repos.tar.gz + +# sbt specific +.cache +.history +.lib/ +dist/* +target/ +lib_managed/ +src_managed/ +project/boot/ +project/plugins/project/ + +# Scala-IDE specific +.scala_dependencies +.worksheet +.idea +.idea.bak/ +intellij/out + + +*~ +docs/xx.md diff --git a/build.sbt b/build.sbt index bb7a329..c8bed50 100644 --- a/build.sbt +++ b/build.sbt @@ -2,10 +2,73 @@ import Dependencies._ def scala211 = "2.11.12" def scala212 = "2.12.9" -def scala213 = "2.13" +def scala213 = "2.13.1" +organization := "io.stasis" name := "stasis" +def scalacOptionsForVersion(version: String): Seq[String] = { + // format: off + val defaultOpts = Seq( + "-deprecation", // Emit warning and location for usages of deprecated APIs. + "-encoding", "utf-8", // Specify character encoding used by source files. + "-explaintypes", // Explain type errors in more detail. + "-feature", // Emit warning and location for usages of features that should be imported explicitly. + "-language:existentials", // Existential types (besides wildcard types) can be written and inferred + "-language:experimental.macros", // Allow macro definition (besides implementation and application) + "-language:higherKinds", // Allow higher-kinded types + "-language:implicitConversions", // Allow definition of implicit functions called views + "-unchecked", // Enable additional warnings where generated code depends on assumptions. + "-Xcheckinit", // Wrap field accessors to throw an exception on uninitialized access. + "-Xlint:adapted-args", // Warn if an argument list is modified to match the receiver. + "-Xlint:constant", // Evaluation of a constant arithmetic expression results in an error. + "-Xlint:delayedinit-select", // Selecting member of DelayedInit. + "-Xlint:doc-detached", // A Scaladoc comment appears to be detached from its element. + "-Xlint:inaccessible", // Warn about inaccessible types in method signatures. + "-Xlint:infer-any", // Warn when a type argument is inferred to be `Any`. + "-Xlint:missing-interpolator", // A string literal appears to be missing an interpolator id. + "-Xlint:nullary-override", // Warn when non-nullary `def f()' overrides nullary `def f'. + "-Xlint:nullary-unit", // Warn when nullary methods return Unit. + "-Xlint:option-implicit", // Option.apply used implicit view. + "-Xlint:package-object-classes", // Class or object defined in package object. + "-Xlint:poly-implicit-overload", // Parameterized overloaded implicit methods are not visible as view bounds. + "-Xlint:private-shadow", // A private field (or class parameter) shadows a superclass field. + "-Xlint:stars-align", // Pattern sequence wildcard must align with sequence component. + "-Xlint:type-parameter-shadow", // A local type parameter shadows a type already in scope. + "-Ywarn-dead-code", // Warn when dead code is identified. + "-Ywarn-extra-implicit", // Warn when more than one implicit parameter section is defined. + "-Ywarn-numeric-widen", // Warn when numerics are widened. + "-Ywarn-unused:implicits", // Warn if an implicit parameter is unused. + "-Ywarn-unused:imports", // Warn if an import selector is not referenced. + "-Ywarn-unused:locals", // Warn if a local definition is unused. + "-Ywarn-unused:params", // Warn if a value parameter is unused. + "-Ywarn-unused:patvars", // Warn if a variable bound in a pattern is unused. + "-Ywarn-unused:privates", // Warn if a private member is unused. + "-Ywarn-value-discard", // Warn when non-Unit expression results are unused. + ) + val versionOpts: Seq[String] = CrossVersion.partialVersion(version) match { + case Some((2, major)) if major < 13 => Seq( + "-Xlint:by-name-right-associative", // By-name parameter of right associative operator. + "-Xlint:unsound-match", // Pattern match may not be typesafe. + "-Xfatal-warnings", // Fail the compilation if there are any warnings. + "-Xfuture", // Turn on future language features. + "-Yno-adapted-args", // Do not adapt an argument list (either by inserting () or creating a tuple) to match the receiver. + "-Ypartial-unification", // Enable partial unification in type constructor inference + "-Ywarn-inaccessible", // Warn about inaccessible types in method signatures. + "-Ywarn-infer-any", // Warn when a type argument is inferred to be `Any`. + "-Ywarn-nullary-override", // Warn when non-nullary `def f()' overrides nullary `def f'. + "-Ywarn-nullary-unit", // Warn when nullary methods return Unit. + ) + case _ => Seq() + } + defaultOpts ++ versionOpts + // format: on +} + +addCompilerPlugin( + ("org.typelevel" %% "kind-projector" % "0.10.3").cross(CrossVersion.binary), +) + inThisBuild( Seq( organization := "io.stasis", @@ -22,14 +85,10 @@ inThisBuild( url("https://greg.burd.me") ) ), - scalaVersion := scala212, + scalaVersion := scala213, crossScalaVersions := List(scala213, scala212, scala211), resolvers += Resolver.sonatypeRepo("releases"), - scalacOptions ++= Seq( - "-unchecked" - , "-deprecation" -// , "-Xfatal-warnings" - ), + scalacOptions ++= scalacOptionsForVersion(scalaVersion.value), libraryDependencies ++= Seq( scalatest.value % Test, scalacheck % Test, @@ -196,3 +255,9 @@ lazy val buildInfoSettings: Seq[Def.Setting[_]] = Seq( buildInfoPackage := "io.stasis", buildInfoObject := "Versions" ) + +// Filter out compiler flags to make the repl experience functional... +val badConsoleFlags = Seq("-Xfatal-warnings", "-Ywarn-unused:imports") +scalacOptions in (Compile, console) ~= (_.filterNot(badConsoleFlags.contains(_))) + +enablePlugins(ScalafmtPlugin, JavaAppPackaging, GhpagesPlugin, MicrositesPlugin, TutPlugin) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 7f0fee1..195ef32 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -5,9 +5,9 @@ import org.portablescala.sbtplatformdeps.PlatformDepsPlugin.autoImport._ object Dependencies { val metaconfigV = "0.8.3" - val scalametaV = "4.0.0" - val scalatestV = "3.2.0-SNAP10" - val scalacheckV = "1.13.5" + val scalametaV = "4.2.3" + val scalatestV = "3.2.0-M1" + val scalacheckV = "1.14.1" val coursier = "1.0.3" val scalapb = Def.setting { diff --git a/project/build.properties b/project/build.properties index dca663d..218101f 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version = 1.2.8 +sbt.version = 1.3.2 diff --git a/project/plugins.sbt b/project/plugins.sbt index 1d8205a..8900152 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -2,20 +2,40 @@ logLevel := Level.Warn resolvers ++= Seq( Classpaths.sbtPluginReleases, + "Local Maven Repository" at Path.userHome.asFile.toURI.toURL + ".m2/repository", + "Local Ivy2 Cache Repository" at Path.userHome.asFile.toURI.toURL + ".ivy2/cache", + Resolver.sonatypeRepo("snapshots"), Resolver.typesafeRepo("releases"), Resolver.sonatypeRepo("releases"), Resolver.bintrayIvyRepo("jetbrains", "sbt-plugins") ) -addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.3.7") + +// Use the Dotty compiler for Scala code. +addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.3.4") + +// Makes our code tidy +addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.0.5") + +// Revolver allows us to use re-start and work a lot faster! +addSbtPlugin("io.spray" % "sbt-revolver" % "0.9.1") + +// Native Packager allows us to create standalone jar +addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.4.1") + +// Documentation plugins +addSbtPlugin("org.tpolecat" % "tut-plugin" % "0.6.12") +addSbtPlugin("com.47deg" % "sbt-microsites" % "0.9.4") +addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3") addSbtPlugin("org.scalameta" % "sbt-mdoc" % "1.2.7") -addSbtPlugin("com.geirsson" % "sbt-scalafmt" % "1.6.0-RC4") + +// Other, TBD +addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.3.4") +addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.9.0") +addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.3.7") addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.2.2") addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.7.0") addSbtPlugin("io.get-coursier" % "sbt-coursier" % "1.0.3") //coursier.util.Properties.version) // "2.0.0-RC2-3" addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.7") addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.3.4") -addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "0.5.0") addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.1.18") -addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.9.0") addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.5.1") -addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.3.4")