Reputation: 3709
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.
[1] http://www.scala-graph.org/download/
Upvotes: 3
Views: 215
Reputation: 170713
First, you need to use "org.scala-lang.modules" %% "scala-swing" % "1.0.1"
for 2.11.
I'm afraid that changes to the graph library, or the swing library, or the scala language itself, will break the code.
Since you have specific fixed versions of both libraries, release of new versions can't affect it; but I certainly would recommend including scalaVersion
anyway. Note in particular that the effect of %%
depends on what your scalaVersion
is.
Upvotes: 3