From 9320cd1ca8786b8357643461e9942f6dad4f503b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillaume=20Mass=C3=A9?= Date: Mon, 16 Oct 2017 22:09:15 +0200 Subject: [PATCH] Support for Scala 2.10 to 2.12 --- .travis.yml | 4 + build.sbt | 79 +++++++++++-------- project/build.properties | 3 +- .../com/github/mdr/ascii/common/Region.scala | 2 +- .../parser/DiagramImplementation.scala | 10 +-- .../ascii/layout/cycles/GraphReflowTest.scala | 2 + .../layering/LongestDistanceToSinkTest.scala | 2 + 7 files changed, 60 insertions(+), 42 deletions(-) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..1ca30b5 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,4 @@ +language: scala +jdk: oraclejdk8 +script: +- sbt +test diff --git a/build.sbt b/build.sbt index 0f4ad5c..c1a9503 100644 --- a/build.sbt +++ b/build.sbt @@ -2,19 +2,25 @@ name := "ascii-graphs" organization := "com.github.mdr" -version := "0.0.6" +version := "0.0.7-SNAPSHOT" -scalaVersion := "2.12.1" +scalaVersion := "2.12.3" -crossScalaVersions := Seq("2.9.1", "2.9.2", "2.10.1") +crossScalaVersions := Seq("2.10.6", "2.11.11", "2.12.3") -scalacOptions ++= Seq("-deprecation") +scalacOptions ++= Seq( + "-deprecation", + "-encoding", + "UTF-8", + "-feature", + "-unchecked" +) -javacOptions ++= Seq("-source", "1.6", "-target", "1.6") -libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.1" % "test" - -libraryDependencies += "org.scalacheck" %% "scalacheck" % "1.13.4" % "test" +libraryDependencies ++= Seq( + "org.scalatest" %% "scalatest" % "3.0.1" % Test, + "org.scalacheck" %% "scalacheck" % "1.13.4" % Test +) // Screen-sized dependency graph: // libraryDependencies += "org.vert-x" % "vertx-core" % "1.3.1.final" @@ -27,7 +33,8 @@ EclipseKeys.eclipseOutput := Some("bin") import com.typesafe.sbt.SbtScalariform.ScalariformKeys -ScalariformKeys.preferences <<= baseDirectory.apply { dir => +ScalariformKeys.preferences := { + val dir = baseDirectory.value scalariform.formatter.preferences.PreferencesImporterExporter.loadPreferences((dir / "formatterPreferences.properties").getPath) } @@ -35,31 +42,35 @@ publishMavenStyle := true publishArtifact in Test := false -publishTo <<= isSnapshot( - if (_) Some("snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/") - else Some("releases" at "https://oss.sonatype.org/service/local/staging/deploy/maven2/")) - -pomExtra := { - 2012 - http://github.com/mdr/ascii-graphs - - - MIT License - http://www.opensource.org/licenses/mit-license.php - repo - - - - git@github.com:mdr/ascii-graphs.git - scm:git:git@github.com:mdr/ascii-graphs - - - - mdr - Matt Russell - https://github.com/mdr/ - - +publishTo := { + val nexus = "https://oss.sonatype.org/" + if (version.value.trim.endsWith("SNAPSHOT")) { + Some("snapshots" at nexus + "content/repositories/snapshots") + } + else { + Some("releases" at nexus + "service/local/staging/deploy/maven2") } +} + +startYear := Some(2012) + +homepage := Some(url("http://github.com/mdr/ascii-graphs")) + +scmInfo := Some( + ScmInfo( + url("https://github.com/mdr/ascii-graphs"), + "scm:git:git@github.com:mdr/ascii-graphs.git" + ) +) + +developers += + Developer( + "mdr", + "Matt Russell", + "MattRussellUK@gmail.com", + url("https://github.com/mdr/") + ) + +licenses := Seq("MIT License" -> url("http://www.opensource.org/licenses/mit-license.php")) // scalacOptions in (Compile, doc) += "-diagrams" diff --git a/project/build.properties b/project/build.properties index 24be09b..406a7d2 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1,2 +1 @@ -sbt.version=0.13.13 - +sbt.version=0.13.16 \ No newline at end of file diff --git a/src/main/scala/com/github/mdr/ascii/common/Region.scala b/src/main/scala/com/github/mdr/ascii/common/Region.scala index aefd372..c586580 100644 --- a/src/main/scala/com/github/mdr/ascii/common/Region.scala +++ b/src/main/scala/com/github/mdr/ascii/common/Region.scala @@ -57,7 +57,7 @@ case class Region(topLeft: Point, bottomRight: Point) extends Translatable[Regio def points: List[Point] = for { - row ← (topRow to bottomRow toList) + row ← (topRow to bottomRow).toList column ← leftColumn to rightColumn } yield Point(row, column) diff --git a/src/main/scala/com/github/mdr/ascii/diagram/parser/DiagramImplementation.scala b/src/main/scala/com/github/mdr/ascii/diagram/parser/DiagramImplementation.scala index 8d6c7f0..89b05dc 100644 --- a/src/main/scala/com/github/mdr/ascii/diagram/parser/DiagramImplementation.scala +++ b/src/main/scala/com/github/mdr/ascii/diagram/parser/DiagramImplementation.scala @@ -30,7 +30,7 @@ trait DiagramImplementation { self: DiagramParser ⇒ val row = start.row def points: List[Point] = - for (column ← start.column to end.column toList) + for (column ← (start.column to end.column).toList) yield Point(row, column) val text: String = { @@ -62,10 +62,10 @@ trait DiagramImplementation { self: DiagramParser ⇒ def contentsRegion: Region = Region(topLeft.right.down, bottomRight.up.left) - val leftBoundary: List[Point] = for (row ← topLeft.row to bottomRight.row toList) yield Point(row, topLeft.column) - val rightBoundary: List[Point] = for (row ← topLeft.row to bottomRight.row toList) yield Point(row, bottomRight.column) - val topBoundary: List[Point] = for (column ← topLeft.column to bottomRight.column toList) yield Point(topLeft.row, column) - val bottomBoundary: List[Point] = for (column ← topLeft.column to bottomRight.column toList) yield Point(bottomRight.row, column) + val leftBoundary: List[Point] = for (row ← (topLeft.row to bottomRight.row).toList) yield Point(row, topLeft.column) + val rightBoundary: List[Point] = for (row ← (topLeft.row to bottomRight.row).toList) yield Point(row, bottomRight.column) + val topBoundary: List[Point] = for (column ← (topLeft.column to bottomRight.column).toList) yield Point(topLeft.row, column) + val bottomBoundary: List[Point] = for (column ← (topLeft.column to bottomRight.column).toList) yield Point(bottomRight.row, column) val boundaryPoints: Set[Point] = leftBoundary.toSet ++ rightBoundary.toSet ++ topBoundary.toSet ++ bottomBoundary.toSet diff --git a/src/test/scala/com/github/mdr/ascii/layout/cycles/GraphReflowTest.scala b/src/test/scala/com/github/mdr/ascii/layout/cycles/GraphReflowTest.scala index 732a9e5..27f0643 100644 --- a/src/test/scala/com/github/mdr/ascii/layout/cycles/GraphReflowTest.scala +++ b/src/test/scala/com/github/mdr/ascii/layout/cycles/GraphReflowTest.scala @@ -4,6 +4,8 @@ import org.scalatest.{FlatSpec, Matchers} import com.github.mdr.ascii.graph.Graph import com.github.mdr.ascii.util.Utils +import scala.language.reflectiveCalls + class GraphReflowTest extends FlatSpec with Matchers { reflowingGraph(""" diff --git a/src/test/scala/com/github/mdr/ascii/layout/layering/LongestDistanceToSinkTest.scala b/src/test/scala/com/github/mdr/ascii/layout/layering/LongestDistanceToSinkTest.scala index 30c47ef..e78934a 100644 --- a/src/test/scala/com/github/mdr/ascii/layout/layering/LongestDistanceToSinkTest.scala +++ b/src/test/scala/com/github/mdr/ascii/layout/layering/LongestDistanceToSinkTest.scala @@ -3,6 +3,8 @@ package com.github.mdr.ascii.layout.layering import org.scalatest.{FlatSpec, Matchers} import com.github.mdr.ascii.graph.Graph +import scala.language.reflectiveCalls + class LongestDistanceToSinkTest extends FlatSpec with Matchers { distancesToSinks("""