Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Specify Dependencies in the Almond Scala Kernel in JupyterLab

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

Jar Dependency

The way to add Jar dependency in Almond is the same as in Ammonite.

interp.load.cp(os.Path("/absolute/path/to/file.jar"))
import $cp.`/absolute/path/to/file.jar`

Maven Dependency

  1. Notice that %% (in interp.load.ivy) and :: (in import $ivy...) automatically suffix the short version of the current Scala distribution (e.g., _2.12) to the artifact name. For example, if your current Scala distribution is 2.12, then the following 2 statements are equivalent.

    interp.load.ivy("org.apache.spark" % "spark-core_2.12" % "2.3.1")
    interp.load.ivy("org.apache.spark" %% "spark-core" % "2.3.1")

    This is specific to Scala. You almost never need to use %% or :: when you add a Java library dependency.

import $ivy.`org.apache.spark:spark-sql_2.12:2.4.2` 
import $ivy.`org.apache.spark::spark-sql:2.4.2` 
interp.load.ivy("org.apache.spark" % "spark-core_2.12" % "2.4.2")
interp.load.ivy("org.apache.spark" %% "spark-sql" % "2.4.2")