In most cases, projects bigger than hello-world require the use of a build-tool.
Popular build-tools for Scala projects are sbt
, maven
and gradle
.
Each of these build tools have their own way of adding dependency libraries to the project.
So, the first question is - which build tool are you even using for your project ?
In case of sbt
, then the project configuration is done using build.sbt
file.
A basic sbt project looks like following,
YourProject
├── build.sbt
├── project
│ └── build.properties
└── src
└── main
└── scala
└── YouCode.scala
You can create this structure manually or if you are using IntelliJ Idea, You can create a new sbt
project simply by using File -> New -> Project -> Scala -> sbt
.
As a beginner, I will strongly suggest that you use IntelliJ Idea with Scala plugin. That will help you in simplifying a lot of things.
For more details on setting things up both using intellj and sbt- https://www.scala-lang.org/download/ .
The project/build.properties
provides the sbt
version used for this project,
sbt.version = 1.3.0
A bare bone build.sbt
looks like following,
name := "YourProject"
version := "1.0"
scalaVersion := "2.12.8"
Now, In your newly created project, you can add the rocks-db library (and other libs) as dependency by adding following to your build.sbt
,
libraryDependencies ++= Seq(
"org.rocksdb" % "rocksdbjni" % "6.2.2",
"some.other" % "some-dependecy" % "other-version",
...
)
I have included the version "6.2.2" in here. As for which version of rocksdb library, that will depend on the version of rocksdb you are connecting to it. Best is to choose the same version as the rocksdb version.