LibraryDependencies += "org.foobar" %% "foobar" % "1.6"Īs you might infer from these examples, entries in build.sbt are simple key/value pairs. Or, if you prefer, you can add them one line at a time to the file, separating each line by a blank line: To add multiple managed dependencies to your project, define them as a Seq in your build.sbt file: LibraryDependencies += "org.scalatest" %% "scalatest" % "1.9.1" % "test" LibraryDependencies += "" % "htmlcleaner" % "2.4"īecause configuration lines in build.sbt must be separated by blank lines, a simple but complete file with one dependency looks like this: If you have a single managed dependency, such as wanting to use the Java HtmlCleaner library in your project, add a libraryDependencies line like this to your build.sbt file: If those JARs depend on other JAR files, you’ll have to download those other JAR files and copy them to the lib directory as well. If you have JAR files (unmanaged dependencies) that you want to use in your project, simply copy them to the lib folder in the root directory of your SBT project, and SBT will find them automatically. You can use both managed and unmanaged dependencies in your SBT projects. You want to use one or more external libraries (dependencies) in your Scala/SBT projects. This is Recipe 18.4, “How to manage dependencies with SBT (Simple Build Tool).” Problem This is an excerpt from the Scala Cookbook (partially modified for the internet).
Next, select Apache Spark pools which pulls up a list of pools to manage. You can add JAR files or Python Wheels files. In the Workspace Packages section, select Upload to add files from your computer. To add packages, navigate to the Manage Hub in Azure Synapse Studio. The most important consideration is that you find a recent version where the Scala version is the same and the Spark version matches (when it’s an external Spark library).
SBT DOWNLOAD SPARK LIBRARIES HOW TO
The video I posted talks a bit more about how to find the right version. To resolve missing dependencies you have to download those JARs and add to your workspace also. However, the library may have additional dependencies that are not included. My preference is to search for the required package on then download the prebuilt JAR file. If you are new to packaging up JAR files that is beyond the scope of this article, but I recommend searching for how to build a “fat jar” so it will include all the dependencies (be sure to mark Spark libraries as provided if they are part of your dependencies).įor open source libraries you may download the correct JAR from a public repository or build the JAR yourself from the source code. To see more details of what is installed on your pool you can checkout the runtime documentation pages for Spark 3.1 and Spark 2.4. Currently for a Spark 3.1 pool you should use Scala 2.12 and for a Spark 2.4 pool use Scala 2.11. When creating custom Scala libraries be sure that the Scala version matches what your Spark pool has installed. In this screenshots for this post I use some dependencies for running Apache Kafka on a Synapse Apache Spark 3.1 pool, but many libraries are available to add.
SBT DOWNLOAD SPARK LIBRARIES CODE
These JAR files could be either third party code or custom built libraries. I recommend using the Workspace packages feature to add JAR files and extend what your Synapse Spark pools can do. There are a variety of ways to add extra JAR files to the set of known libraries on your Spark cluster, but with Synapse Spark pools the options are a little different than a standard Apache Spark installation. External libraries for JVM will be packaged as JAR files. The Spark source code has a whole directory of external Spark modules ( ) that can be added in but are not installed on every Spark environment by default. Installing JAR files (for Java/Scala libraries)Īdding additional libraries to the Java Virtual Machine (Java/Scala code) is a common way to get additional functionality available in Apache Spark.