diff --git a/.travis.yml b/.travis.yml index a56498a..b854eed 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/build.sbt b/build.sbt index 3fd0f8e..28015d0 100644 --- a/build.sbt +++ b/build.sbt @@ -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:git@github.com:lihaoyi/acyclic.git" +)) + +licenses := Seq("MIT" -> url("http://www.opensource.org/licenses/mit-license.html")) + +homepage := Some(url("https://github.com/lihaoyi/acyclic")) -pomExtra := ( - https://github.com/lihaoyi/acyclic - - - MIT license - http://www.opensource.org/licenses/mit-license.php - - - - git://github.com/lihaoyi/utest.git - scm:git://github.com/lihaoyi/acyclic.git - - - - lihaoyi - Li Haoyi - https://github.com/lihaoyi - - - ) +developers += Developer( + email = "haoyi.sg@gmail.com", + id = "lihaoyi", + name = "Li Haoyi", + url = url("https://github.com/lihaoyi") +) \ No newline at end of file diff --git a/project/build.properties b/project/build.properties index 817bc38..0cd8b07 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=0.13.9 +sbt.version=1.2.3 diff --git a/project/build.sbt b/project/build.sbt index 7a1f37d..1d9667a 100644 --- a/project/build.sbt +++ b/project/build.sbt @@ -1,2 +1,3 @@ -addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0") \ No newline at end of file +addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.1") +addSbtPlugin("com.dwijnand" % "sbt-travisci" % "1.1.3") diff --git a/src/main/scala-2.10_2.12/acyclic/plugin/Compat.scala b/src/main/scala-2.10_2.12/acyclic/plugin/Compat.scala new file mode 100644 index 0000000..b421a78 --- /dev/null +++ b/src/main/scala-2.10_2.12/acyclic/plugin/Compat.scala @@ -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]) + +} \ No newline at end of file diff --git a/src/main/scala-2.13/acyclic/plugin/Compat.scala b/src/main/scala-2.13/acyclic/plugin/Compat.scala new file mode 100644 index 0000000..e195a41 --- /dev/null +++ b/src/main/scala-2.13/acyclic/plugin/Compat.scala @@ -0,0 +1,5 @@ +package acyclic.plugin + +import acyclic.file + +object Compat diff --git a/src/main/scala/acyclic/plugin/GraphAnalysis.scala b/src/main/scala/acyclic/plugin/GraphAnalysis.scala index bf72ce3..b405cf0 100644 --- a/src/main/scala/acyclic/plugin/GraphAnalysis.scala +++ b/src/main/scala/acyclic/plugin/GraphAnalysis.scala @@ -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){ diff --git a/src/main/scala/acyclic/plugin/PluginPhase.scala b/src/main/scala/acyclic/plugin/PluginPhase.scala index eaee91a..4e8adbc 100644 --- a/src/main/scala/acyclic/plugin/PluginPhase.scala +++ b/src/main/scala/acyclic/plugin/PluginPhase.scala @@ -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 @@ -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 ) } @@ -112,6 +114,7 @@ class PluginPhase(val global: Global, .flatMap(_.dependencies.toSeq) .groupBy(_._1) .mapValues(_.flatMap(_._2)) + .toMap ) } @@ -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")