Skip to content

Commit

Permalink
Merge pull request #28 from alexarchambault/2.13
Browse files Browse the repository at this point in the history
Add scala 2.13.0-M5 support
  • Loading branch information
alexarchambault authored Sep 27, 2018
2 parents bc41cd0 + c33b317 commit aa0a75d
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 44 deletions.
14 changes: 5 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
language: scala
scala:
- 2.10.6
- 2.11.8
- 2.12.0
- 2.10.7
- 2.11.12
- 2.12.6
- 2.13.0-M5
jdk:
- oraclejdk8
- openjdk7
matrix:
exclude:
- scala: 2.12.0
jdk: openjdk7
script:
- sbt ++$TRAVIS_SCALA_VERSION "test-only -- --truncate=999999"
- sbt ++$TRAVIS_SCALA_VERSION "testOnly -- --truncate=999999"
# Tricks to avoid unnecessary cache updates, from
# http://www.scala-sbt.org/0.13/docs/Travis-CI-with-sbt.html
- find $HOME/.sbt -name "*.lock" | xargs rm
Expand Down
61 changes: 30 additions & 31 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,49 +1,48 @@

organization := "com.lihaoyi"

name := "acyclic"

version := "0.1.7"

scalaVersion := "2.11.8"

crossScalaVersions := Seq("2.10.6", "2.11.8", "2.12.0")
version := "0.1.8"

resolvers += Resolver.sonatypeRepo("releases")

libraryDependencies ++= Seq(
"com.lihaoyi" %% "utest" % "0.4.4" % "test",
"com.lihaoyi" %% "utest" % "0.6.6" % "test",
"org.scala-lang" % "scala-compiler" % scalaVersion.value % "provided"
)

unmanagedSourceDirectories.in(Compile) ++= {
CrossVersion.partialVersion(scalaBinaryVersion.value) match {
case Some((2, n)) if n == 10 || n == 11 || n == 12 =>
Seq(baseDirectory.value / "src" / "main" / "scala-2.10_2.12")
case Some((2, 13)) =>
Seq(baseDirectory.value / "src" / "main" / "scala-2.13")
case _ =>
Nil
}
}

testFrameworks += new TestFramework("utest.runner.Framework")

unmanagedSourceDirectories in Test <+= baseDirectory(_ / "src" / "test" / "resources")
unmanagedSourceDirectories in Test += baseDirectory.value / "src" / "test" / "resources"

// Sonatype
publishArtifact in Test := false

publishTo <<= version { (v: String) =>
Some("releases" at "https://oss.sonatype.org/service/local/staging/deploy/maven2")
}
publishTo := Some("releases" at "https://oss.sonatype.org/service/local/staging/deploy/maven2")

scmInfo := Some(ScmInfo(
browseUrl = url("https://github.com/lihaoyi/acyclic"),
connection = "scm:git:[email protected]:lihaoyi/acyclic.git"
))

licenses := Seq("MIT" -> url("http://www.opensource.org/licenses/mit-license.html"))

homepage := Some(url("https://github.com/lihaoyi/acyclic"))

pomExtra := (
<url>https://github.com/lihaoyi/acyclic</url>
<licenses>
<license>
<name>MIT license</name>
<url>http://www.opensource.org/licenses/mit-license.php</url>
</license>
</licenses>
<scm>
<url>git://github.com/lihaoyi/utest.git</url>
<connection>scm:git://github.com/lihaoyi/acyclic.git</connection>
</scm>
<developers>
<developer>
<id>lihaoyi</id>
<name>Li Haoyi</name>
<url>https://github.com/lihaoyi</url>
</developer>
</developers>
)
developers += Developer(
email = "[email protected]",
id = "lihaoyi",
name = "Li Haoyi",
url = url("https://github.com/lihaoyi")
)
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=0.13.9
sbt.version=1.2.3
3 changes: 2 additions & 1 deletion project/build.sbt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@

addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.1")
addSbtPlugin("com.dwijnand" % "sbt-travisci" % "1.1.3")
24 changes: 24 additions & 0 deletions src/main/scala-2.10_2.12/acyclic/plugin/Compat.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package acyclic.plugin

import acyclic.file

import scala.collection.{SortedSet, SortedSetLike}
import scala.collection.mutable.Builder
import scala.collection.generic.{CanBuildFrom, SortedSetFactory}
import scala.language.implicitConversions

object Compat {

// from https://github.com/scala/scala-collection-compat/blob/746a7de28223812b19d0d9f68d2253e0c5f655ca/compat/src/main/scala-2.11_2.12/scala/collection/compat/CompatImpl.scala#L8-L11
private def simpleCBF[A, C](f: => Builder[A, C]): CanBuildFrom[Any, A, C] = new CanBuildFrom[Any, A, C] {
def apply(from: Any): Builder[A, C] = apply()
def apply(): Builder[A, C] = f
}

// from https://github.com/scala/scala-collection-compat/blob/746a7de28223812b19d0d9f68d2253e0c5f655ca/compat/src/main/scala-2.11_2.12/scala/collection/compat/PackageShared.scala#L46-L49
implicit def sortedSetCompanionToCBF[A: Ordering,
CC[X] <: SortedSet[X] with SortedSetLike[X, CC[X]]](
fact: SortedSetFactory[CC]): CanBuildFrom[Any, A, CC[A]] =
simpleCBF(fact.newBuilder[A])

}
5 changes: 5 additions & 0 deletions src/main/scala-2.13/acyclic/plugin/Compat.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package acyclic.plugin

import acyclic.file

object Compat
2 changes: 1 addition & 1 deletion src/main/scala/acyclic/plugin/GraphAnalysis.scala
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ trait GraphAnalysis{
.filter(!distances.contains(_))

children.foreach(distances(_) = distances(next) + 1)
queue.enqueue(children.toSeq:_*)
queue ++= children
}
var route = List(from)
while(route.length == 1 || route.head != from){
Expand Down
5 changes: 4 additions & 1 deletion src/main/scala/acyclic/plugin/PluginPhase.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

package acyclic.plugin
import acyclic.file
import acyclic.plugin.Compat._
import scala.collection.{SortedSet, mutable}
import scala.tools.nsc.{Global, Phase}
import tools.nsc.plugins.PluginComponent
Expand Down Expand Up @@ -94,6 +95,7 @@ class PluginPhase(val global: Global,
Value.File(unit.source.path, pkgName(unit)),
connections.groupBy(c => Value.File(c._1, pkgName(unitMap(c._1))): Value)
.mapValues(_.map(_._2))
.toMap
)
}

Expand All @@ -112,6 +114,7 @@ class PluginPhase(val global: Global,
.flatMap(_.dependencies.toSeq)
.groupBy(_._1)
.mapValues(_.flatMap(_._2))
.toMap
)
}

Expand Down Expand Up @@ -142,7 +145,7 @@ class PluginPhase(val global: Global,
.map{ case Seq(a, b) => (a.value, a.dependencies(b.value))}
.toSeq
cycleReporter(
cycleInfo.map{ case (a, b) => a -> b.map(_.pos.line).to[SortedSet]}
cycleInfo.map{ case (a, b) => a -> b.map(_.pos.line).to(SortedSet)}
)

global.error("Unwanted cyclic dependency")
Expand Down

0 comments on commit aa0a75d

Please sign in to comment.