3

New to Scala and sbt; coming from a python world, and rather confused by library dependencies, versioning, and what sbt can and cannot automatically download (i.e. when a .jar needs to be manually placed in /lib).

I want to use classes from the Scala geoscript project (http://geoscript.org/scala/quickstart.html) in my Scala app.

I'm using IntelliJ with Scala 2.11.8.

Can I ultimately do something like:

libraryDependencies += "org.geoscript" % "some-artifact" % some=version

Or is this going to be an "unmanaged dependency"? And if so, what's the cleanest way to do that?

EyeWrite
  • 233
  • 2
  • 6

1 Answers1

1

If a dependency jar is published to Maven Central and some other repositories, sbt will automatically be able to resolve and download it when declaring it as libraryDependency. This is a "managed dependency". Usually a library's documentation will tell you the "coordinates" (group id, artifact id, version) you need to install it.

From the page you linked and the Maven search, it looks like Geoscript is not published, so you will have to add it to your /lib folder in the project. That should be enough to put it in the classpath. You may need to refresh the project for IntelliJ to pick it up and offer completions.

Justin Kaeser
  • 5,868
  • 27
  • 46
  • Thanks for the response Justin. I tried to build and then package the project into a .jar, and added that to my project's external libraries. While the import statements worked (intelliJ was able to locate the classes), actually using the library threw a lot of "unresolved symbol" despite the successful imports - some further underlying dependencies issues. In any case, I'm going to KISS, and find an alternative geospatial project included in Maven Central. Thanks! – EyeWrite Jul 20 '17 at 15:57
  • If you package up your own jar based on the other library and use it in yet another project, you will need to put both your and the other jar on the classpath. sbt does this for you with managed dependencies, but with unmanged you have to do it yourself – Justin Kaeser Jul 20 '17 at 17:40