I am trying to use scala-graph and scala-swing in the same program. I can use the latest graph-core library (1.9.2) alone with the latest version of scala (2.11.6). I can use scala-swing, but when I do that, sbt gives me Scala 2.10.4 rather than 2.11.6.
When I tried to use both libraries, I got errors -- either compilation or runtime errors, depending on how I set up build.sbt. So I tried using an older version of graph-core (1.8.0), which if I understand the library's release history [1] correctly, was designed for Scala 2.10.
Doing that works, although it causes sbt to use scala 2.10.4 instead of 2.11.6. I'm worried because it seems like a fragile arrangement.
Will it keep working? Currently my build.sbt file (below) does not restrict the scalaVersion or the scala-compiler version; it just says which graph and swing libraries to use. I'm afraid that changes to the graph library, or the swing library, or the scala language itself, will break the code.
[The rest of this post describes my OS, installations, and code; you might not need to read it.]
I am using Ubuntu 14.04. I installed scala and sbt using apt-get. swing appears already to be installed on my machine. I did not install the graph library but sbt seems to take care of it.
My only two files are in the same folder: build.sbt and main.scala. The build.sbt looks like this:
lazy val root = (project in file(".")).
settings(
name := "main",
version := "1.0",
libraryDependencies += "org.scala-lang" % "scala-swing" % "2.10.5",
libraryDependencies += "com.assembla.scala-incubator" %% "graph-core" % "1.8.0"
)
main.scala looks like this:
import scalax.collection.Graph // or scalax.collection.mutable.Graph
import scalax.collection.GraphPredef._, scalax.collection.GraphEdge._
import scala.swing._, scala.swing.event._
object App extends SimpleSwingApplication {
def top = new MainFrame {
val g1 = Graph(3~1, 5) // no effect; just tests the constructor
val button = new Button { text = "Click me" }
contents = new BoxPanel(Orientation.Vertical) {
contents += button
border = Swing.EmptyBorder(30, 30, 10, 30)
}
}
}
Thanks.