3

I'm writing Java code in a Jupyter Notebook via IJava . I want to add external dependencies such as OpenCSV. Using gradle, this would normally be incorporated in the build.gradle file via the line

compile 'com.opencsv:opencsv:4.3.2'

How can I add dependencies at runtime via gradle in the Jupyter notebook?

Mark Teese
  • 651
  • 5
  • 16

1 Answers1

6

There is the maven magic for this. Since the dependency is on maven central, it is as easy as adding %maven com.opencsv:opencsv:4.3.2 in a cell.

For example

%maven com.opencsv:opencsv:4.3.2
import com.opencsv.CSVReader;
// ...

The name maven is slightly misleading as Maven (or Gradle) is a build tool rather than strictly a dependency manager, but as the dependencies are often resolved from the Maven Central repository the notion of adding a "maven dependency" was a good enough metaphor.

SpencerPark
  • 3,298
  • 1
  • 15
  • 27