DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Coding
  3. Languages
  4. Proper SBT Setup for Scala 2.10 and Spark Streaming

Proper SBT Setup for Scala 2.10 and Spark Streaming

Learn how to set up SBT for Scala 2.10 and Spark streaming, from the directory to build properties.

Tim Spann user avatar by
Tim Spann
CORE ·
Mar. 22, 16 · Tutorial
Like (3)
Save
Tweet
Share
12.32K Views

Join the DZone community and get the full member experience.

Join For Free

The first step on your way to building Spark Jobs in Scala is to setup your project.   Below is a listing of a proper directory structure and SBT build files.

Directory

project
   build.properties
   assembly.sbt
   plugins.sbt

build.sbt

src/main/scala

src/main/resources

To Assembly Our Jar for Spark, sbt assembly. The first time, I like to do sbt clean assembly.   For my example, it is assumed you have Scala 2.10.x on MacOSX or Linux with Spark 1.6 installed.

build.sbt

name := "MySparkScala"

version := "1.0"

scalaVersion := "2.10.5"

// Configure JAR used with the assembly plug-in
jarName in assembly := "MySparkScala.jar"

ivyScala := ivyScala.value map { _.copy(overrideScalaVersion = true) }

libraryDependencies  ++= Seq(

  "org.apache.ignite" % "ignite-spark_2.10" % "1.4.0",
  "org.apache.ignite" % "ignite-spring" % "1.4.0",
  "org.apache.spark" % "spark-core_2.10" % "1.4.1" % "provided",
  "org.apache.spark" % "spark-sql_2.10" % "1.4.1" % "provided",
  "org.scalanlp" %% "breeze-viz" % "0.11.2",
  "com.github.nscala-time" %% "nscala-time" % "2.2.0",
  "org.apache.commons" % "commons-math3" % "3.5" % "provided"
)

assemblyOption in assembly := (assemblyOption in assembly).value.copy(includeScala = false)

resolvers ++= Seq(
  "Sonatype Releases" at "https://oss.sonatype.org/content/repositories/releases/"
)

mergeStrategy in assembly := {
  case m if m.toLowerCase.endsWith("manifest.mf")          => MergeStrategy.discard
  case m if m.toLowerCase.matches("meta-inf.*\\.sf$")      => MergeStrategy.discard
  case "log4j.properties"                                  => MergeStrategy.discard
  case m if m.toLowerCase.startsWith("meta-inf/services/") => MergeStrategy.filterDistinctLines
  case "reference.conf"                                    => MergeStrategy.concat
  case _                                                   => MergeStrategy.first
}

build.properties

sbt.version = 0.13.8%

assembly.sbt

addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.11.2")

That's how to start, and you're ready to build your first Scala-based Apache Spark application.

Scala (programming language)

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Top Authentication Trends to Watch Out for in 2023
  • PHP vs React
  • RabbitMQ vs. Memphis.dev
  • 7 Awesome Libraries for Java Unit and Integration Testing

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: