Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Scala to 2.13 #1522

Merged
merged 18 commits into from
Oct 17, 2019
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,26 @@ jobs:
- env: TEST="2.12"
jdk: openjdk8
script: sbt ci-test
- env: TEST="2.13"
jdk: openjdk8
script: sbt ci-test
- env: TEST="2.11"
jdk: openjdk11
script: sbt ci-test
- env: TEST="2.12"
jdk: openjdk11
script: sbt ci-test
- env: TEST="2.13"
jdk: openjdk11
script: sbt ci-test
- stage: release
jdk: openjdk8
script: sbt ci-release docs/docusaurusPublishGhpages

cache:
directories:
- $HOME/.sbt
- $HOME/.sbt/1.0/dependency
- $HOME/.sbt/launchers
poslegm marked this conversation as resolved.
Show resolved Hide resolved
- $HOME/.ivy2/cache
- $HOME/.coursier
- target/repos
Expand Down
41 changes: 33 additions & 8 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import sbtcrossproject.CrossPlugin.autoImport.crossProject

def scala211 = "2.11.12"
def scala212 = "2.12.8"
def scala213 = "2.13.1"

inThisBuild(
List(
Expand All @@ -19,8 +20,8 @@ inThisBuild(
url("https://geirsson.com")
)
),
scalaVersion := scala212,
crossScalaVersions := List(scala212, scala211),
scalaVersion := scala213,
crossScalaVersions := List(scala213, scala212, scala211),
resolvers += Resolver.sonatypeRepo("releases"),
libraryDependencies ++= List(
scalatest.value % Test,
Expand All @@ -36,7 +37,8 @@ skip in publish := true
commands += Command.command("ci-test") { s =>
val scalaVersion = sys.env.get("TEST") match {
case Some("2.11") => scala211
case _ => scala212
case Some("2.12") => scala212
case _ => scala213
}
val docsTest = if (scalaVersion == scala212) "docs/run" else "version"
s"++$scalaVersion" ::
Expand Down Expand Up @@ -89,17 +91,26 @@ lazy val core = crossProject(JVMPlatform)
.in(file("scalafmt-core"))
.settings(
moduleName := "scalafmt-core",
addCompilerPlugin(
poslegm marked this conversation as resolved.
Show resolved Hide resolved
"org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full
),
buildInfoSettings,
scalacOptions ++= scalacJvmOptions.value,
libraryDependencies ++= Seq(
metaconfig.value,
scalameta.value,
// scala-reflect is an undeclared dependency of fansi, see #1252.
// Scalafmt itself does not require scala-reflect.
"org.scala-lang" % "scala-reflect" % scalaVersion.value
)
),
libraryDependencies ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 13)) => Seq.empty
case _ =>
Seq(
compilerPlugin(
"org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full
)
)
}
}
)
// .jsSettings(
// libraryDependencies ++= List(
Expand All @@ -122,6 +133,7 @@ import sbtassembly.AssemblyPlugin.defaultUniversalScript
val scalacJvmOptions = Def.setting {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 11)) => Seq("-target:jvm-1.8")
case Some((2, 13)) => Seq("-Ymacro-annotations")
case _ => Seq.empty
}
}
Expand All @@ -141,6 +153,15 @@ lazy val cli = project
// undeclared transitive dependency of coursier-small
"org.scala-lang.modules" %% "scala-xml" % "1.2.0"
),
libraryDependencies ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 13)) =>
Seq(
"org.scala-lang.modules" %% "scala-parallel-collections" % "0.2.0"
)
case _ => Seq.empty
}
},
scalacOptions ++= scalacJvmOptions.value
)
.dependsOn(coreJVM, dynamic)
Expand All @@ -151,7 +172,10 @@ lazy val tests = project
skip in publish := true,
libraryDependencies ++= Seq(
// Test dependencies
"com.lihaoyi" %% "scalatags" % "0.6.8",
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 13)) => "com.lihaoyi" %% "scalatags" % "0.7.0"
case _ => "com.lihaoyi" %% "scalatags" % "0.6.8"
},
"org.typelevel" %% "paiges-core" % "0.2.4",
scalametaTestkit
)
Expand Down Expand Up @@ -215,6 +239,7 @@ lazy val buildInfoSettings: Seq[Def.Setting[_]] = Seq(
"stable" -> stableVersion.value,
"scala" -> scalaVersion.value,
"scala211" -> scala211,
"scala212" -> scala212,
"coursier" -> coursier,
"commit" -> sys.process.Process("git rev-parse HEAD").lineStream_!.head,
"timestamp" -> System.currentTimeMillis().toString,
Expand Down
6 changes: 3 additions & 3 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import org.portablescala.sbtplatformdeps.PlatformDepsPlugin.autoImport._
// scalafmt: { maxColumn = 120, style = defaultWithAlign }

object Dependencies {
val metaconfigV = "0.8.3"
val metaconfigV = "0.9.4"
val scalametaV = "4.2.3"
val scalatestV = "3.2.0-SNAP10"
val scalacheckV = "1.13.5"
val scalatestV = "3.0.8"
val scalacheckV = "1.14.2"
val coursier = "1.0.3"

val scalapb = Def.setting {
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.2.6
sbt.version=1.2.8
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ resolvers ++= Seq(
Resolver.bintrayIvyRepo("jetbrains", "sbt-plugins")
)

addSbtPlugin("org.scalameta" % "sbt-mdoc" % "1.2.7")
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "1.3.5")
addSbtPlugin("com.geirsson" % "sbt-scalafmt" % "1.6.0-RC4")
addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.4.31")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.7.0")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,41 +1,14 @@
package org.scalafmt.benchmarks

import scala.collection.GenIterable
import scala.meta.Source
import scala.meta.testkit.Corpus
import scala.meta.testkit.CorpusFile
import scala.util.Try
package benchmarks

import java.util.concurrent.TimeUnit

import org.openjdk.jmh.annotations.Benchmark
import org.openjdk.jmh.annotations.BenchmarkMode
import org.openjdk.jmh.annotations.Measurement
import org.openjdk.jmh.annotations.Mode
import org.openjdk.jmh.annotations.OutputTimeUnit
import org.openjdk.jmh.annotations.Scope
import org.openjdk.jmh.annotations.Setup
import org.openjdk.jmh.annotations.Warmup
import org.openjdk.jmh.annotations._
import org.scalafmt.Scalafmt
import org.scalafmt.config.RewriteSettings
import org.scalafmt.config.ScalafmtConfig
import org.scalafmt.rewrite.RedundantBraces
import org.scalafmt.rewrite.SortImports
import org.scalafmt.benchmarks.FormatBenchmark

trait FormatBenchmark {
def formatRewrite(code: String) = {
Scalafmt
.format(
code,
style = ScalafmtConfig.default.copy(
rewrite = RewriteSettings(
rules = Seq(SortImports, RedundantBraces)
)
)
)
.get
}
}
import scala.collection.GenIterable
import scala.meta.testkit.Corpus
import scala.util.Try

/**
* Formats filename at with scalafmt.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.scalafmt.benchmarks

import org.scalafmt.Scalafmt
import org.scalafmt.config.{RewriteSettings, ScalafmtConfig}
import org.scalafmt.rewrite.{RedundantBraces, SortImports}

trait FormatBenchmark {
def formatRewrite(code: String): String = {
Scalafmt
.format(
code,
style = ScalafmtConfig.default.copy(
rewrite = RewriteSettings(
rules = Seq(SortImports, RedundantBraces)
)
)
)
.get
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,9 @@ package org.scalafmt.benchmarks
import java.io.File
import java.util.concurrent.TimeUnit

import org.openjdk.jmh.annotations.Benchmark
import org.openjdk.jmh.annotations.BenchmarkMode
import org.openjdk.jmh.annotations.Measurement
import org.openjdk.jmh.annotations.Mode
import org.openjdk.jmh.annotations.OutputTimeUnit
import org.openjdk.jmh.annotations.Scope
import org.openjdk.jmh.annotations.Setup
import org.openjdk.jmh.annotations.Warmup
import org.openjdk.jmh.annotations._
import org.scalafmt.Scalafmt
import org.scalafmt.util.FileOps
import scala.meta.Source

import org.scalafmt.config.RedundantBracesSettings
import org.scalafmt.config.RewriteSettings
import org.scalafmt.config.ScalafmtOptimizer
import org.scalafmt.config.ScalafmtRunner
import org.scalafmt.config.ScalafmtConfig
import org.scalafmt.rewrite.RedundantBraces
import org.scalafmt.rewrite.SortImports

/**
* Formats filename at [[path]] with scalafmt.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.scalafmt.benchmarks

import benchmarks.MacroBenchmark
import org.scalafmt.benchmarks.Micro.ScalaJsFile
import org.scalatest.FunSuite

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.scalafmt.cli

private[cli] object CompatParCollections {
val Converters = {
import Compat._
{
import scala.collection.parallel._
CollectionConverters
}
}

object Compat {
object CollectionConverters
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package org.scalafmt.cli

import java.util.concurrent.atomic.{AtomicInteger, AtomicReference}
import java.util.function.UnaryOperator

import metaconfig.Configured
import org.scalafmt.Error.{MisformattedFile, NoMatchingFiles}
import org.scalafmt.{Formatted, Scalafmt, Versions}
import org.scalafmt.config.{FilterMatcher, ScalafmtConfig}
import org.scalafmt.cli.CompatParCollections.Converters._
import org.scalafmt.util.OsSpecific

import scala.meta.internal.tokenizers.PlatformTokenizerCache
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ object Terminal {
None

implicit class Ansi(val output: Writer) extends AnyVal {
private def control(n: Int, c: Char) = output.write(s"\033[" + n + c)
private def control(n: Int, c: Char) = output.write("\u001b[" + n + c)

/**
* Move up `n` squares
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ trait ScalafmtConfDecoders {
implicit lazy val eventReader: ConfDecoder[FormatEvent => Unit] =
ConfDecoder.instance[FormatEvent => Unit] {
case _ =>
Configured.Ok((_: FormatEvent) => Unit)
Configured.Ok((_: FormatEvent) => ())
}
implicit lazy val parseReader: ConfDecoder[MetaParser] = {
ReaderUtil.oneOf[MetaParser](parseSource, parseStat, parseCase)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import scala.meta.parsers.Parse
*/
case class ScalafmtRunner(
debug: Boolean = false,
eventCallback: FormatEvent => Unit = _ => Unit,
eventCallback: FormatEvent => Unit = _ => (),
parser: Parse[_ <: Tree] = Parse.parseSource,
optimizer: ScalafmtOptimizer = ScalafmtOptimizer.default,
maxStateVisits: Int = 1000000,
Expand Down Expand Up @@ -84,7 +84,7 @@ object ScalafmtRunner {
*/
val default = ScalafmtRunner(
debug = false,
eventCallback = _ => Unit,
eventCallback = _ => (),
parser = scala.meta.parsers.Parse.parseSource,
optimizer = ScalafmtOptimizer.default,
maxStateVisits = 1000000
Expand Down
Loading