Skip to content

Commit

Permalink
sbt: refactor: sbt-avro settings
Browse files Browse the repository at this point in the history
  • Loading branch information
suhailshergill committed Feb 5, 2015
1 parent 24d8e9a commit aaf3e80
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 39 deletions.
74 changes: 35 additions & 39 deletions project/Project.scala
Expand Up @@ -34,8 +34,6 @@ object ScalabootBuild extends Build {
"clojars.org" at "http://clojars.org/repo")

val hadoopDeps = Seq(
"com.twitter" %% "scalding-core" % "0.10.0",
"com.twitter" %% "scalding-avro" % "0.10.0",
"com.twitter" %% "scalding-commons" % "0.10.0"
// "org.apache.hadoop" % "hadoop-core" % "2.3.0-mr1-cdh5.0.1" % "provided",
)
Expand Down Expand Up @@ -63,46 +61,44 @@ object ScalabootBuild extends Build {

import sbtassembly.Plugin._
import AssemblyKeys._
import sbtavro.SbtAvro._

lazy val hadoopSettings = defaultSettings ++ assemblySettings ++ avroSettings ++ Seq(
resolvers ++= hadoopResolvers,
libraryDependencies ++= hadoopDeps,

version in avroConfig := "1.7.5", // remove this if you want cdh5 avro to be
// pulled in
stringType in avroConfig := "String",
lazy val hadoopSettings = defaultSettings ++
assemblySettings ++
sbtAvro.settings ++
Seq(
resolvers ++= hadoopResolvers,
libraryDependencies ++= hadoopDeps,

// Slightly cleaner jar name
jarName in assembly := { name.value + "-" + version.value + ".jar" },
test in assembly := {}, // ignore tests
mainClass in assembly := Some(HADOOP_JOBRUNNER),
// NOTE: specifying the main class for Compile,run is currently somewhat
// buggy because of this
// [[https://github.com/sbt/sbt/issues/850][bug]]. it's also not really
// needed but adding here for completeness
mainClass in (Compile, run) := Some(HADOOP_JOBRUNNER),
// Drop these jars
excludedJars in assembly <<= (fullClasspath in assembly) map { cp =>
val excludes: Set[String] = Set(
"minlog-1.2.jar" // Otherwise causes conflicts with Kryo (which bundles it)
, "commons-beanutils-core-1.8.0.jar" // Clash with each other and with commons-collections
, "commons-beanutils-1.7.0.jar" // "
, "asm-3.1.jar" // there's already asm-4.0
, "jsp-2.1-6.1.14.jar"
)
cp filter { jar => excludes(jar.data.getName) }
},
// Slightly cleaner jar name
jarName in assembly := { name.value + "-" + version.value + ".jar" },
test in assembly := {}, // ignore tests
mainClass in assembly := Some(HADOOP_JOBRUNNER),
// NOTE: specifying the main class for Compile,run is currently somewhat
// buggy because of this
// [[https://github.com/sbt/sbt/issues/850][bug]]. it's also not really
// needed but adding here for completeness
mainClass in (Compile, run) := Some(HADOOP_JOBRUNNER),
// Drop these jars
excludedJars in assembly <<= (fullClasspath in assembly) map { cp =>
val excludes: Set[String] = Set(
"minlog-1.2.jar" // Otherwise causes conflicts with Kryo (which bundles it)
, "commons-beanutils-core-1.8.0.jar" // Clash with each other and with commons-collections
, "commons-beanutils-1.7.0.jar" // "
, "asm-3.1.jar" // there's already asm-4.0
, "jsp-2.1-6.1.14.jar"
)
cp filter { jar => excludes(jar.data.getName) }
},

mergeStrategy in assembly <<= (mergeStrategy in assembly) {
(old) =>
{
case PathList("javax", "servlet", xs @ _*) => MergeStrategy.first
case PathList(ps @ _*) if ps.last endsWith ".html" => MergeStrategy.first
case "project.clj" => MergeStrategy.discard // Leiningen build files
case x => old(x)
}
})
mergeStrategy in assembly <<= (mergeStrategy in assembly) {
(old) =>
{
case PathList("javax", "servlet", xs @ _*) => MergeStrategy.first
case PathList(ps @ _*) if ps.last endsWith ".html" => MergeStrategy.first
case "project.clj" => MergeStrategy.discard // Leiningen build files
case x => old(x)
}
})

lazy val root = Project(PROJECT_NAME, file("."))
.configs(IntegrationTest)
Expand Down
File renamed without changes.
19 changes: 19 additions & 0 deletions project/sbtAvro.scala
@@ -0,0 +1,19 @@
object sbtAvro {
import sbt._
import sbtavro.SbtAvro._

private lazy val deps = Seq(
"com.twitter" %% "scalding-core" % "0.10.0"
, "com.twitter" %% "scalding-avro" % "0.10.0"
)


lazy val settings = avroSettings ++ Seq(
Keys.resolvers += "sbt-plugin-releases" at
"http://repo.scala-sbt.org/scalasbt/sbt-plugin-releases"
, Keys.libraryDependencies ++= deps
, Keys.version in avroConfig := "1.7.5" // remove this if you want cdh5 avro
// to be pulled in
, stringType in avroConfig := "String"
)
}

0 comments on commit aaf3e80

Please sign in to comment.