In scala-cli, external libraries can be easily downloaded and used in scripts and REPLs using a convenient notation called using directive.
On the other hand, the worksheet functionality provided by IDEs such as Metals allows you to download external libraries in the same way using import $ivy
or import $dep
.
However, worksheets cannot make use of the using directive (at least as of mdoc v2.3.7) (mdoc is the library used behind the scenes to provide the worksheet functionality).
Which notations can be used in which environments? It's a bit confusing, so I'll leave a note.
// using dep |
import $ivy |
import $dep |
|
---|---|---|---|
scala-cli | ⭕️ | ❌ | ❌ |
Ammonite | ❌ | ⭕️ | ❌ |
IntelliJ worksheet (Ammonite) | ❌ | ⭕️ | ❌ |
Metals Worksheet | ❌ | ⭕️ | ⭕️ |
Note
- scala-cli dropped ammonite imports
-
import $dep
is available only in mdoc-build tools Add support for adding library dependencies via imports. by olafurpg · Pull Request #333 · scalameta/mdoc such as metals worksheet. - Follow the Scala worksheet, Scala REPL and Ammonite | IntelliJ IDEA Documentation to use Ammonite in IntelliJ worksheet.
Top comments (0)