How to add MATSim to my Scala project using SBT?

Viewed 46

I am trying to use MATSim with Scala and SBT. I cannot, however, add the dependencies without compilation errors. MATSim uses Maven, but I want to add it to my SBT project. Here is my build.sbt.

name := "matsim-console"

version := "0.1"

scalaVersion := "2.13.7"

lazy val matsimVersion = "13.0"

resolvers += "osgeo" at "https://repo.osgeo.org/repository/release/"
resolvers += "matsim" at "https://repo.matsim.org/repository/matsim"
resolvers += "jogl" at "https://dl.bintray.com/matsim/matsim/"
resolvers += Resolver.url("jogl1", url("https://mvnrepository.com/artifact/"))( Patterns("[organisation]/[module]/[revision]/[artifact].[ext]") )

lazy val proj = (project in file("."))
  .settings(
    libraryDependencies += "org.jogamp.jogl" % "jogl-all" % "2.4.0-matsim-1",
    libraryDependencies += "org.jogamp.gluegen" % "gluegen-rt" % "2.3.2",
    libraryDependencies += "org.matsim" % "matsim" % matsimVersion,
    libraryDependencies += "org.matsim.contrib" % "vsp" % matsimVersion,
  )

1- Why do I need to add the dependencies of jog-all and gluegen-rt to my Scala project? Shouldn't SBT import MATSim with all its dependencies?

2- Why isn't the last dependency working? I get this error:

[error] stack trace is suppressed; run last update for the full output
[error] (update) lmcoursier.internal.shaded.coursier.error.FetchError$DownloadingArtifacts: Error fetching artifacts:
[error] https://repo.matsim.org/repository/matsim/org/jogamp/jogl/jogl-all/2.4.0-matsim-1/jogl-all-2.4.0-matsim-1-natives-solaris-amd64.jar: not found: https://repo.matsim.org/repository/matsim/org/jogamp/jogl/jogl-all/2.4.0-matsim-1/jogl-all-2.4.0-matsim-1-natives-solaris-amd64.jar
[error] https://repo.matsim.org/repository/matsim/org/jogamp/jogl/jogl-all/2.4.0-matsim-1/jogl-all-2.4.0-matsim-1-natives-android-armv6.jar: not found: https://repo.matsim.org/repository/matsim/org/jogamp/jogl/jogl-all/2.4.0-matsim-1/jogl-all-2.4.0-matsim-1-natives-android-armv6.jar
[error] https://repo.matsim.org/repository/matsim/org/jogamp/gluegen/gluegen-rt/2.4.0-matsim-1/gluegen-rt-2.4.0-matsim-1-natives-linux-armv6.jar: not found: https://repo.matsim.org/repository/matsim/org/jogamp/gluegen/gluegen-rt/2.4.0-matsim-1/gluegen-rt-2.4.0-matsim-1-natives-linux-armv6.jar
[error] https://repo.matsim.org/repository/matsim/org/jogamp/jogl/jogl-all/2.4.0-matsim-1/jogl-all-2.4.0-matsim-1-natives-solaris-i586.jar: not found: https://repo.matsim.org/repository/matsim/org/jogamp/jogl/jogl-all/2.4.0-matsim-1/jogl-all-2.4.0-matsim-1-natives-solaris-i586.jar
[error] https://repo.matsim.org/repository/matsim/org/jogamp/gluegen/gluegen-rt/2.4.0-matsim-1/gluegen-rt-2.4.0-matsim-1-natives-android-armv6.jar: not found: https://repo.matsim.org/repository/matsim/org/jogamp/gluegen/gluegen-rt/2.4.0-matsim-1/gluegen-rt-2.4.0-matsim-1-natives-android-armv6.jar
[error] https://repo.matsim.org/repository/matsim/org/jogamp/jogl/jogl-all/2.4.0-matsim-1/jogl-all-2.4.0-matsim-1-natives-linux-armv6hf.jar: not found: https://repo.matsim.org/repository/matsim/org/jogamp/jogl/jogl-all/2.4.0-matsim-1/jogl-all-2.4.0-matsim-1-natives-linux-armv6hf.jar
[error] https://repo.matsim.org/repository/matsim/org/jogamp/jogl/jogl-all/2.4.0-matsim-1/jogl-all-2.4.0-matsim-1-natives-linux-armv6.jar: not found: https://repo.matsim.org/repository/matsim/org/jogamp/jogl/jogl-all/2.4.0-matsim-1/jogl-all-2.4.0-matsim-1-natives-linux-armv6.jar
[error] https://repo.matsim.org/repository/matsim/org/jogamp/gluegen/gluegen-rt/2.4.0-matsim-1/gluegen-rt-2.4.0-matsim-1-natives-linux-armv6hf.jar: not found: https://repo.matsim.org/repository/matsim/org/jogamp/gluegen/gluegen-rt/2.4.0-matsim-1/gluegen-rt-2.4.0-matsim-1-natives-linux-armv6hf.jar
[error] https://repo.matsim.org/repository/matsim/org/jogamp/gluegen/gluegen-rt/2.4.0-matsim-1/gluegen-rt-2.4.0-matsim-1-natives-android-aarch64.jar: not found: https://repo.matsim.org/repository/matsim/org/jogamp/gluegen/gluegen-rt/2.4.0-matsim-1/gluegen-rt-2.4.0-matsim-1-natives-android-aarch64.jar
[error] https://repo.matsim.org/repository/matsim/org/jogamp/gluegen/gluegen-rt/2.4.0-matsim-1/gluegen-rt-2.4.0-matsim-1-natives-solaris-i586.jar: not found: https://repo.matsim.org/repository/matsim/org/jogamp/gluegen/gluegen-rt/2.4.0-matsim-1/gluegen-rt-2.4.0-matsim-1-natives-solaris-i586.jar
[error] https://repo.matsim.org/repository/matsim/org/jogamp/jogl/jogl-all/2.4.0-matsim-1/jogl-all-2.4.0-matsim-1-natives-android-aarch64.jar: not found: https://repo.matsim.org/repository/matsim/org/jogamp/jogl/jogl-all/2.4.0-matsim-1/jogl-all-2.4.0-matsim-1-natives-android-aarch64.jar
[error] https://repo.matsim.org/repository/matsim/org/jogamp/gluegen/gluegen-rt/2.4.0-matsim-1/gluegen-rt-2.4.0-matsim-1-natives-solaris-amd64.jar: not found: https://repo.matsim.org/repository/matsim/org/jogamp/gluegen/gluegen-rt/2.4.0-matsim-1/gluegen-rt-2.4.0-matsim-1-natives-solaris-amd64.jar
2 Answers

Why do I need to add the dependencies of jog-all and gluegen-rt to my Scala project? Shouldn't SBT import MatSim with all its dependencies?

Right. You don't need to, that's the purpose of a dependency management tool like SBT. Just add the dependency you need directly and the transitive dependencies will be pulled automatically.

Why isn't the last dependency working? I get this error

Because it's somehow looking for a dependency that doesn't exist (or at least not in the repositories you provided).

You should use sbt dependencyTree (or variants) to have a better view of the dependencies and see why this dependency is wanted.

It worked correctly, as it should, when I switched to Java 11.

Related