Skip to content

Commit

Permalink
Merge pull request #980 from olafurpg/scala-2.13
Browse files Browse the repository at this point in the history
Upgrade to Scala 2.12.10
  • Loading branch information
olafurpg authored Sep 12, 2019
2 parents f3ceb98 + c5c5041 commit 75db131
Show file tree
Hide file tree
Showing 31 changed files with 174 additions and 159 deletions.
17 changes: 8 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
language: scala
jdk:
- openjdk8
stages:
Expand All @@ -12,21 +11,21 @@ before_install:
fi
jobs:
include:
- env: TEST="scalafmt"
- name: Scalafmt
script: ./scalafmt --test
- env: TEST="2.11"
script: sbt ci-211
- env: TEST="2.12"
script: sbt ci-212
- name: 2.11
script: ./sbt ci-211
- name: 2.12
script: ./sbt ci-212
- jdk: openjdk11
env: TEST="2.12"
script: sbt ci-212
name: 2.12
script: ./sbt ci-212

# Disabled until stable v0.6
# - env: TEST="mima"
# script: sbt mima
- stage: release
script: sbt ci-release docs/docusaurusPublishGhpages
script: ./sbt ci-release docs/docusaurusPublishGhpages

cache:
directories:
Expand Down
20 changes: 15 additions & 5 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import Dependencies._
inThisBuild(
List(
onLoadMessage := s"Welcome to scalafix ${version.value}",
scalaVersion := "2.12.8",
crossScalaVersions := List("2.12.8", "2.11.12")
scalaVersion := scala212,
crossScalaVersions := List(scala212, scala211)
)
)

Expand All @@ -22,13 +22,15 @@ def inferJavaHome() = {
lazy val interfaces = project
.in(file("scalafix-interfaces"))
.settings(
noMima,
resourceGenerators.in(Compile) += Def.task {
val props = new java.util.Properties()
props.put("scalafixVersion", version.value)
props.put("scalafixStableVersion", stableVersion.value)
props.put("scalametaVersion", scalametaV)
props.put("scala212", scala212)
props.put("scala211", scala211)
props.put("scala213", scala213)
val out =
managedResourceDirectories.in(Compile).value.head /
"scalafix-interfaces.properties"
Expand Down Expand Up @@ -107,14 +109,21 @@ lazy val testsShared = project
coverageEnabled := false
)

val isScala213 = Def.setting(scalaVersion.value.startsWith("2.13"))

val warnAdaptedArgs = Def.setting {
if (isScala213.value) "-Xlint:adapted-args"
else "-Ywarn-adapted-args"
}

lazy val testsInput = project
.in(file("scalafix-tests/input"))
.settings(
noPublish,
semanticdbSettings,
scalacOptions ~= (_.filterNot(_ == "-Yno-adapted-args")),
scalacOptions += "-Ywarn-adapted-args", // For NoAutoTupling
scalacOptions += "-Ywarn-unused-import", // For RemoveUnusedImports
scalacOptions += warnAdaptedArgs.value, // For NoAutoTupling
scalacOptions += warnUnusedImports.value, // For RemoveUnused
scalacOptions += "-Ywarn-unused", // For RemoveUnusedTerms
logLevel := Level.Error, // avoid flood of compiler warnings
testsInputOutputSetting,
Expand All @@ -127,7 +136,7 @@ lazy val testsOutput = project
noPublish,
semanticdbSettings,
scalacOptions --= List(
warnUnusedImports,
warnUnusedImports.value,
"-Xlint"
),
testsInputOutputSetting,
Expand All @@ -137,6 +146,7 @@ lazy val testsOutput = project
lazy val testkit = project
.in(file("scalafix-testkit"))
.settings(
noMima,
moduleName := "scalafix-testkit",
isFullCrossVersion,
libraryDependencies ++= Seq(
Expand Down
23 changes: 11 additions & 12 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import sbt._
/* scalafmt: { maxColumn = 120 }*/

object Dependencies {
val scalametaV = "4.2.1"
val metaconfigV = "0.9.1"
def dotty = "0.9.0-RC1"
def scala210 = "2.10.6"
val scalametaV = "4.2.3"
val metaconfigV = "0.9.4"
def scala210 = "2.10.7"
def scala211 = "2.11.12"
def scala212 = "2.12.8"
def scala212 = "2.12.10"
def scala213 = "2.13.0"
val currentScalaVersion = scala212

val jgit = "org.eclipse.jgit" % "org.eclipse.jgit" % "4.5.4.201711221230-r"
Expand All @@ -20,17 +20,16 @@ object Dependencies {
def metacp = "org.scalameta" %% "metacp" % scalametaV
def semanticdbPluginLibrary = "org.scalameta" % "semanticdb-scalac-core" % scalametaV cross CrossVersion.full
def scalameta = "org.scalameta" %% "scalameta" % scalametaV
def scalatest = "org.scalatest" %% "scalatest" % "3.2.0-SNAP10"
def scalatest = "org.scalatest" %% "scalatest" % "3.0.8"
def scalacheck = "org.scalacheck" %% "scalacheck" % "1.14.0"

def testsDeps = List(
// integration property tests
"com.geirsson" %% "coursier-small" % "1.0.0-M4",
"org.scala-lang.modules" %% "scala-xml" % "1.1.0",
"org.typelevel" %% "catalysts-platform" % "0.0.5",
"org.typelevel" %% "cats-core" % "0.9.0",
"com.typesafe.slick" %% "slick" % "3.2.0-M2",
"com.chuusai" %% "shapeless" % "2.3.2",
"io.get-coursier" %% "coursier" % "2.0.0-RC3-3",
"org.scala-lang.modules" %% "scala-xml" % "1.2.0",
"org.typelevel" %% "cats-core" % "2.0.0-RC1",
"com.typesafe.slick" %% "slick" % "3.3.2",
"com.chuusai" %% "shapeless" % "2.3.3",
scalacheck
)

Expand Down
50 changes: 31 additions & 19 deletions project/ScalafixBuild.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,26 @@ object ScalafixBuild extends AutoPlugin with GhpagesKeys {
lazy val isFullCrossVersion = Seq(
crossVersion := CrossVersion.full
)
lazy val warnUnusedImports = "-Ywarn-unused-import"
lazy val isScala213 = Def.setting {
scalaVersion.value.startsWith("2.13")
}
lazy val warnUnusedImports = Def.setting {
if (isScala213.value) "-Ywarn-unused:imports"
else "-Ywarn-unused-import"
}
lazy val scaladocOptions = Seq(
"-groups",
"-implicits"
// "-diagrams"
)
lazy val compilerOptions = Seq(
"-target:jvm-1.8",
warnUnusedImports,
"-deprecation",
"-encoding",
"UTF-8",
"-feature",
"-unchecked"
lazy val compilerOptions = Def.setting(
Seq(
"-target:jvm-1.8",
warnUnusedImports.value,
"-encoding",
"UTF-8",
"-feature",
"-unchecked"
)
)

lazy val buildInfoSettings: Seq[Def.Setting[_]] = Seq(
Expand Down Expand Up @@ -163,16 +169,13 @@ object ScalafixBuild extends AutoPlugin with GhpagesKeys {

override def globalSettings: Seq[Def.Setting[_]] = List(
stableVersion := version.in(ThisBuild).value.replaceFirst("\\+.*", ""),
scalacOptions ++= compilerOptions,
scalacOptions
.in(Compile, console) := compilerOptions :+ "-Yrepl-class-based",
libraryDependencies ++= List(
scalacheck % Test,
scalatest % Test
),
resolvers ++= List(
Resolver.sonatypeRepo("snapshots"),
Resolver.sonatypeRepo("releases"),
Resolver.sonatypeRepo("public"),
Resolver.mavenLocal
),
testOptions in Test += Tests.Argument("-oD"),
Expand All @@ -182,20 +185,25 @@ object ScalafixBuild extends AutoPlugin with GhpagesKeys {
"unit/test:runMain scalafix.tests.util.SaveExpect" ::
s
},
commands += Command.command("ci-213") { s =>
s"++$scala213" ::
"unit/test" ::
s
},
commands += Command.command("ci-212") { s =>
"++2.12.8" ::
s"++$scala212" ::
"unit/test" ::
"docs/run" ::
"interfaces/doc" ::
s
},
commands += Command.command("ci-211") { s =>
"++2.11.12" ::
s"++$scala211" ::
"unit/test" ::
s
},
commands += Command.command("ci-212-windows") { s =>
"++2.12.8" ::
s"++$scala212" ::
s"unit/testOnly -- -l scalafix.internal.tests.utils.SkipWindows" ::
s
},
Expand Down Expand Up @@ -266,10 +274,14 @@ object ScalafixBuild extends AutoPlugin with GhpagesKeys {
private val PreviousScalaVersion = Map(
"2.11.12" -> "2.11.11",
"2.12.4" -> "2.12.3",
"2.12.8" -> "2.12.7"
"2.12.8" -> "2.12.7",
"2.12.10" -> "2.12.8"
)

override def projectSettings: Seq[Def.Setting[_]] = List(
scalacOptions ++= compilerOptions.value,
scalacOptions.in(Compile, console) :=
compilerOptions.value :+ "-Yrepl-class-based",
scalacOptions.in(Compile, doc) ++= scaladocOptions,
publishTo := Some {
if (isCustomRepository) "adhoc" at adhocRepoUri
Expand All @@ -283,7 +295,7 @@ object ScalafixBuild extends AutoPlugin with GhpagesKeys {
)
),
mimaPreviousArtifacts := {
val previousArtifactVersion = "0.5.0"
val previousArtifactVersion = "0.9.6"
// NOTE(olafur) shudder, can't figure out simpler way to do the same.
val binaryVersion =
if (crossVersion.value.isInstanceOf[CrossVersion.Full]) {
Expand Down
2 changes: 1 addition & 1 deletion project/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.23")
addSbtPlugin("io.get-coursier" % "sbt-coursier" % "1.1.0-M8")
addSbtPlugin("io.get-coursier" % "sbt-coursier" % "2.0.0-RC3-3")
unmanagedSources.in(Compile) += baseDirectory.value / ".." / "Dependencies.scala"
Binary file added sbt
Binary file not shown.
57 changes: 29 additions & 28 deletions scalafix-cli/src/main/scala/scalafix/internal/v1/MainOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -77,37 +77,38 @@ object MainOps {
}
}

def files(args: ValidatedArgs): Seq[AbsolutePath] = args.args.ls match {
case Ls.Find =>
val buf = ArrayBuffer.empty[AbsolutePath]
val visitor = new SimpleFileVisitor[Path] {
override def visitFile(
file: Path,
attrs: BasicFileAttributes
): FileVisitResult = {
val path = AbsolutePath(file)
val relpath = path.toRelative(args.sourceroot)
if (args.matches(relpath)) {
buf += path
def files(args: ValidatedArgs): collection.Seq[AbsolutePath] =
args.args.ls match {
case Ls.Find =>
val buf = ArrayBuffer.empty[AbsolutePath]
val visitor = new SimpleFileVisitor[Path] {
override def visitFile(
file: Path,
attrs: BasicFileAttributes
): FileVisitResult = {
val path = AbsolutePath(file)
val relpath = path.toRelative(args.sourceroot)
if (args.matches(relpath)) {
buf += path
}
FileVisitResult.CONTINUE
}
FileVisitResult.CONTINUE
}
}

val roots =
if (args.args.files.isEmpty) args.sourceroot :: Nil
else args.args.files
val roots =
if (args.args.files.isEmpty) args.sourceroot :: Nil
else args.args.files

roots.foreach { root =>
if (root.isFile) {
if (args.matches(root.toRelative(args.args.cwd))) {
buf += root
}
} else if (root.isDirectory) Files.walkFileTree(root.toNIO, visitor)
else args.config.reporter.error(s"$root is not a file")
}
buf.result()
}
roots.foreach { root =>
if (root.isFile) {
if (args.matches(root.toRelative(args.args.cwd))) {
buf += root
}
} else if (root.isDirectory) Files.walkFileTree(root.toNIO, visitor)
else args.config.reporter.error(s"$root is not a file")
}
buf.result()
}

final class StaleSemanticDB(val path: AbsolutePath, val diff: String)
extends Exception(s"Stale SemanticDB\n$diff")
Expand All @@ -129,7 +130,7 @@ object MainOps {
def adjustExitCode(
args: ValidatedArgs,
code: ExitStatus,
files: Seq[AbsolutePath]
files: collection.Seq[AbsolutePath]
): ExitStatus = {
if (args.callback.hasLintErrors) {
ExitStatus.merge(ExitStatus.LinterError, code)
Expand Down
8 changes: 8 additions & 0 deletions scalafix-core/src/main/scala-2.11/scalafix/util/Compat.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package scalafix.util

import scala.collection.immutable.IndexedSeq

object Compat {
type View[T] = collection.SeqView[T, IndexedSeq[T]]
type SeqView[T] = collection.SeqView[T, IndexedSeq[T]]
}
8 changes: 8 additions & 0 deletions scalafix-core/src/main/scala-2.12/scalafix/util/Compat.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package scalafix.util

import scala.collection.immutable.IndexedSeq

object Compat {
type View[T] = collection.SeqView[T, IndexedSeq[T]]
type SeqView[T] = collection.Seq[T]
}
6 changes: 6 additions & 0 deletions scalafix-core/src/main/scala-2.13/scalafix/util/Compat.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package scalafix.util

object Compat {
type View[T] = collection.View[T]
type SeqView[T] = collection.SeqView[T]
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package scalafix.internal.config

import metaconfig._
import metaconfig.Configured.Ok
import metaconfig.Configured.NotOk
import metaconfig.generic.Surface
import scala.meta._
import scala.meta.dialects.Scala212
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ object ImportPatchOps {
allImporters.toIterator
.filter(_.importees.forall(isRemovedImportee))
.toSet
def removeSpaces(tokens: scala.Seq[Token]): Patch = {
def removeSpaces(tokens: Iterable[Token]): Patch = {
tokens
.takeWhile {
case Token.Space() => true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ final class InternalSemanticDoc(
}
result
}

private[this] lazy val occurrences: util.Map[s.Range, Seq[String]] = {
private[this] lazy val occurrences
: util.Map[s.Range, collection.Seq[String]] = {
val result = new util.HashMap[s.Range, ListBuffer[String]]()
textDocument.occurrences.foreach { o =>
if (o.range.isDefined) {
Expand All @@ -114,7 +114,7 @@ final class InternalSemanticDoc(
buffer += o.symbol
}
}
result.asInstanceOf[util.Map[s.Range, Seq[String]]]
result.asInstanceOf[util.Map[s.Range, collection.Seq[String]]]
}

}
Loading

0 comments on commit 75db131

Please sign in to comment.