Consolidate dependencies

Project: http://git-wip-us.apache.org/repos/asf/incubator-toree/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-toree/commit/bf02de54
Tree: http://git-wip-us.apache.org/repos/asf/incubator-toree/tree/bf02de54
Diff: http://git-wip-us.apache.org/repos/asf/incubator-toree/diff/bf02de54

Branch: refs/heads/master
Commit: bf02de5415fab3cad7a815e88624a64b8a59825c
Parents: abcc0c8
Author: Jakob Odersky <[email protected]>
Authored: Mon Feb 13 15:17:41 2017 -0800
Committer: Jakob Odersky <[email protected]>
Committed: Wed Feb 15 15:24:09 2017 -0800

----------------------------------------------------------------------
 client/build.sbt           |  8 ++---
 communication/build.sbt    |  8 ++---
 kernel-api/build.sbt       | 20 ++++++-------
 kernel/build.sbt           |  3 +-
 macros/build.sbt           |  8 +++--
 plugins/build.sbt          | 11 +++----
 project/Dependencies.scala | 66 +++++++++++++++++++++++++++++++++++++++++
 project/common.scala       | 64 +++++++++++++--------------------------
 protocol/build.sbt         |  8 ++---
 9 files changed, 117 insertions(+), 79 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-toree/blob/bf02de54/client/build.sbt
----------------------------------------------------------------------
diff --git a/client/build.sbt b/client/build.sbt
index 5c2ca7e..1ee62a7 100644
--- a/client/build.sbt
+++ b/client/build.sbt
@@ -19,7 +19,7 @@ scalacOptions += "-language:reflectiveCalls"
 
 // Main library dependencies to function
 libraryDependencies ++= Seq(
-  "com.typesafe.akka" %% "akka-actor" % "2.4.8",
-  "com.typesafe.akka" %% "akka-slf4j" % "2.4.8",
-  "com.typesafe.akka" %% "akka-testkit" % "2.4.8" % "test"
-)
\ No newline at end of file
+  Dependencies.akkaActor,
+  Dependencies.akkaSlf4j,
+  Dependencies.akkaTestkit % "test"
+)

http://git-wip-us.apache.org/repos/asf/incubator-toree/blob/bf02de54/communication/build.sbt
----------------------------------------------------------------------
diff --git a/communication/build.sbt b/communication/build.sbt
index 8d0bee6..92db418 100644
--- a/communication/build.sbt
+++ b/communication/build.sbt
@@ -16,8 +16,8 @@
  */
 
 libraryDependencies ++= Seq(
-  "org.zeromq"        % "jeromq"        % "0.3.6",
-  "com.typesafe.akka" %% "akka-actor"   % "2.4.8",
-  "com.typesafe.akka" %% "akka-slf4j"   % "2.4.8",
-  "com.typesafe.akka" %% "akka-testkit" % "2.4.8" % "test"
+  Dependencies.jeroMq,
+  Dependencies.akkaActor,
+  Dependencies.akkaSlf4j,
+  Dependencies.akkaTestkit % "test"
 )

http://git-wip-us.apache.org/repos/asf/incubator-toree/blob/bf02de54/kernel-api/build.sbt
----------------------------------------------------------------------
diff --git a/kernel-api/build.sbt b/kernel-api/build.sbt
index 26e9d6f..e1ab494 100644
--- a/kernel-api/build.sbt
+++ b/kernel-api/build.sbt
@@ -28,35 +28,33 @@ ivyConfigurations += Configurations.ScalaTool
 // Add the usual dependency on the library as well on the compiler in the
 //  'scala-tool' configuration
 libraryDependencies ++= Seq(
-  "org.scala-lang" % "scala-library" % scalaVersion.value,
-  "org.scala-lang" % "scala-compiler" % scalaVersion.value % "scala-tool",
-  "org.scala-lang" % "scala-reflect" % scalaVersion.value
+  Dependencies.scalaLibrary.value,
+  Dependencies.scalaCompiler.value % "scala-tool",
+  Dependencies.scalaReflect.value
 )
 
 //
 // EXECUTION DEPENDENCIES
 //
-libraryDependencies += "org.apache.commons" % "commons-exec" % "1.3"
+libraryDependencies += Dependencies.commonsExec
 
 //
 // CLI DEPENDENCIES
 //
-libraryDependencies += "net.sf.jopt-simple" % "jopt-simple" % "4.6" // MIT
+libraryDependencies += Dependencies.joptSimple
 
 
-libraryDependencies += "com.typesafe" % "config" % "1.3.0"
+libraryDependencies += Dependencies.config
 
 //
 // MAGIC DEPENDENCIES
 //
 libraryDependencies ++= Seq(
-  // Used to find and download jars from Maven-based repositories
-  "org.apache.ivy" % "ivy" % "2.4.0-rc1", // Apache v2
-  "io.get-coursier" %% "coursier" % "1.0.0-M14", // Apache v2
-  "io.get-coursier" %% "coursier-cache" % "1.0.0-M14" // Apache v2
+  Dependencies.coursier,
+  Dependencies.coursierCache
 )
 
 // Brought in in order to simplify the reading of each project's ivy.xml file
 // from the classpath. If we really want we can write our own class and remove
 // this dependency but the wheel has already been invented.
-libraryDependencies += "org.springframework" % "spring-core" % "4.1.1.RELEASE" 
// Apache v2
+libraryDependencies += Dependencies.springCore // Apache v2

http://git-wip-us.apache.org/repos/asf/incubator-toree/blob/bf02de54/kernel/build.sbt
----------------------------------------------------------------------
diff --git a/kernel/build.sbt b/kernel/build.sbt
index 0965dce..752ad2a 100644
--- a/kernel/build.sbt
+++ b/kernel/build.sbt
@@ -18,6 +18,5 @@
 //
 // TEST DEPENDENCIES
 //
-libraryDependencies +=
-  "com.typesafe.akka" %% "akka-testkit" % "2.4.8" % "test" // MIT
+libraryDependencies += Dependencies.akkaTestkit % "test"
 

http://git-wip-us.apache.org/repos/asf/incubator-toree/blob/bf02de54/macros/build.sbt
----------------------------------------------------------------------
diff --git a/macros/build.sbt b/macros/build.sbt
index 4083071..65eda08 100644
--- a/macros/build.sbt
+++ b/macros/build.sbt
@@ -15,9 +15,11 @@
  *  limitations under the License
  */
 // Do not export a jar for this or publish anything (should serve just as a 
pre-processor)
-libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value
+libraryDependencies += Dependencies.scalaReflect.value
 
 libraryDependencies ++= (
-  if (scalaVersion.value.startsWith("2.10")) List("org.scalamacros" %% 
"quasiquotes" % "2.1.0")
-  else Nil
+  if (scalaVersion.value.startsWith("2.10"))
+    List("org.scalamacros" %% "quasiquotes" % "2.1.0")
+  else
+    Nil
 )

http://git-wip-us.apache.org/repos/asf/incubator-toree/blob/bf02de54/plugins/build.sbt
----------------------------------------------------------------------
diff --git a/plugins/build.sbt b/plugins/build.sbt
index 56cdc85..99f1701 100644
--- a/plugins/build.sbt
+++ b/plugins/build.sbt
@@ -17,13 +17,10 @@
 
 // Needed for type inspection
 libraryDependencies ++= Seq(
-  "org.scala-lang" % "scala-reflect" % scalaVersion.value,
-  // BSD 3-clause license, used for detecting plugins
-  "org.clapper" %% "classutil" % "1.0.12",
-  "org.slf4j" % "slf4j-api" % "1.7.21" // MIT
+  Dependencies.scalaReflect.value,
+  Dependencies.clapper,
+  Dependencies.slf4jApi
 )
 
 // Test dependencies
-libraryDependencies ++= Seq(
-  "org.scala-lang" % "scala-compiler" % scalaVersion.value % "test"
-)
+libraryDependencies += Dependencies.scalaCompiler.value % "test"

http://git-wip-us.apache.org/repos/asf/incubator-toree/blob/bf02de54/project/Dependencies.scala
----------------------------------------------------------------------
diff --git a/project/Dependencies.scala b/project/Dependencies.scala
new file mode 100644
index 0000000..2efdf35
--- /dev/null
+++ b/project/Dependencies.scala
@@ -0,0 +1,66 @@
+import sbt._
+import sbt.Keys._
+import scala.util.Properties
+
+object Dependencies {
+
+  val sparkVersion = Def.setting{
+    //sLog.value.warn("danger!")
+    val envVar = "APACHE_SPARK_VERSION"
+    val defaultVersion = "2.0.0"
+
+    Properties.envOrNone(envVar) match {
+      case None =>
+        sLog.value.info(s"Using default Apache Spark version $defaultVersion!")
+        defaultVersion
+      case Some(version) =>
+        sLog.value.info(s"Using Apache Spark version $version, provided from 
$envVar")
+        version
+    }
+  }
+
+  val akkaActor = "com.typesafe.akka" %% "akka-actor" % "2.4.17"
+  val akkaSlf4j = "com.typesafe.akka" %% "akka-slf4j" % "2.4.17"
+  val akkaTestkit = "com.typesafe.akka" %% "akka-testkit" % "2.4.17"
+
+  val clapper = "org.clapper" %% "classutil" % "1.0.12" // BSD 3-clause 
license, used for detecting plugins
+
+  val commonsExec = "org.apache.commons" % "commons-exec" % "1.3"
+
+  val config = "com.typesafe" % "config" % "1.3.0"
+
+  // Apache v2
+  val coursier = "io.get-coursier" %% "coursier" % "1.0.0-M15-1"
+  val coursierCache = "io.get-coursier" %% "coursier-cache" % "1.0.0-M15-1"
+
+  val ivy = "org.apache.ivy" % "ivy" % "2.4.0-rc1" // Apache v2
+
+  // use the same jackson version in test than the one provided at runtime by 
Spark 2.0.0
+  val jacksonDatabind = "com.fasterxml.jackson.core" % "jackson-databind" % 
"2.6.5" // Apache v2
+
+  val jeroMq = "org.zeromq" % "jeromq" % "0.3.6"
+
+  val joptSimple = "net.sf.jopt-simple" % "jopt-simple" % "4.6" // MIT
+
+  val mockito = "org.mockito" % "mockito-all" % "1.10.19" // MIT
+
+  val playJson = "com.typesafe.play" %% "play-json" % "2.3.10" // Apache v2
+
+  val scalaCompiler = Def.setting{ "org.scala-lang" % "scala-compiler" % 
scalaVersion.value }
+  val scalaLibrary = Def.setting{ "org.scala-lang" % "scala-library" % 
scalaVersion.value }
+  val scalaReflect = Def.setting{ "org.scala-lang" % "scala-reflect" % 
scalaVersion.value }
+
+  val scalaTest = "org.scalatest" %% "scalatest" % "2.2.6" // Apache v2
+
+  val slf4jApi = "org.slf4j" % "slf4j-api" % "1.7.21" // MIT
+
+  val sparkCore = Def.setting{ "org.apache.spark" %% "spark-core" % 
sparkVersion.value }
+  val sparkGraphX = Def.setting{ "org.apache.spark" %% "spark-graphx" % 
sparkVersion.value }
+  val sparkMllib = Def.setting{ "org.apache.spark" %% "spark-mllib" % 
sparkVersion.value }
+  val sparkRepl = Def.setting{ "org.apache.spark" %% "spark-repl" % 
sparkVersion.value }
+  val sparkSql = Def.setting{ "org.apache.spark" %% "spark-sql" % 
sparkVersion.value }
+  val sparkStreaming = Def.setting{ "org.apache.spark" %% "spark-streaming" % 
sparkVersion.value }
+
+  val springCore = "org.springframework" % "spring-core" % "4.1.1.RELEASE"// 
Apache v2
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-toree/blob/bf02de54/project/common.scala
----------------------------------------------------------------------
diff --git a/project/common.scala b/project/common.scala
index 560ff4a..2e87135 100644
--- a/project/common.scala
+++ b/project/common.scala
@@ -24,6 +24,8 @@ import scoverage.ScoverageSbtPlugin
 import com.typesafe.sbt.pgp.PgpKeys._
 import scala.util.{Try, Properties}
 
+import Dependencies.sparkVersion
+
 object Common {
   //  Parameters for publishing to artifact repositories
   private val versionNumber             = Properties.envOrElse("VERSION", 
"0.0.0-dev")
@@ -36,7 +38,7 @@ object Common {
 //  private val buildScalaVersion         = "2.10.6"
 
   val buildInfoSettings = Seq(
-    buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion, 
sbtVersion, "sparkVersion" -> sparkVersion),
+    buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion, 
sbtVersion, "sparkVersion" -> sparkVersion.value),
     buildInfoPackage := buildOrganization,
     buildInfoUsePackageAsPath := true,
     buildInfoOptions += BuildInfoOption.BuildTime
@@ -69,7 +71,20 @@ object Common {
         fork in SystemTest := doFork,
         fork in ScratchTest := doFork,
         libraryDependencies ++= (
-          if (needsSpark) sparkLibraries
+          if (needsSpark) Seq(
+            Dependencies.sparkCore.value % "provided" excludeAll(
+              // Exclude netty (org.jboss.netty is for 3.2.2.Final only)
+              ExclusionRule(
+                organization = "org.jboss.netty",
+                name = "netty"
+              )
+            ),
+            Dependencies.sparkGraphX.value % "provided",
+            Dependencies.sparkMllib.value % "provided",
+            Dependencies.sparkRepl.value % "provided",
+            Dependencies.sparkSql.value % "provided",
+            Dependencies.sparkStreaming.value % "provided"
+          )
           else Nil
         )
       )
@@ -90,44 +105,6 @@ object Common {
   lazy val SystemTest = config("system") extend Test
   lazy val ScratchTest = config("scratch") extend Test
 
-  private lazy val sparkVersion = {
-    val sparkEnvironmentVariable = "APACHE_SPARK_VERSION"
-    val defaultSparkVersion = "2.0.0"
-
-    val _sparkVersion = Properties.envOrNone(sparkEnvironmentVariable)
-
-    if (_sparkVersion.isEmpty) {
-      scala.Console.out.println(
-        s"""
-           |[INFO] Using default Apache Spark $defaultSparkVersion!
-           """.stripMargin.trim.replace('\n', ' '))
-      defaultSparkVersion
-    } else {
-      val version = _sparkVersion.get
-      scala.Console.out.println(
-        s"""
-           |[INFO] Using Apache Spark $version provided from
-                                                |$sparkEnvironmentVariable!
-           """.stripMargin.trim.replace('\n', ' '))
-      version
-    }
-  }
-
-  private val sparkLibraries = Seq(
-    "org.apache.spark" %% "spark-core" % sparkVersion  % "provided" 
excludeAll( // Apache v2
-      // Exclude netty (org.jboss.netty is for 3.2.2.Final only)
-      ExclusionRule(
-        organization = "org.jboss.netty",
-        name = "netty"
-      )
-    ),
-    "org.apache.spark" %% "spark-streaming" % sparkVersion % "provided",
-    "org.apache.spark" %% "spark-sql" % sparkVersion % "provided",
-    "org.apache.spark" %% "spark-mllib" % sparkVersion % "provided",
-    "org.apache.spark" %% "spark-graphx" % sparkVersion % "provided",
-    "org.apache.spark" %% "spark-repl" % sparkVersion  % "provided"
-  )
-
   val commonSettings: Seq[Def.Setting[_]] = Seq(
     organization := buildOrganization,
     useGpg := true,
@@ -145,10 +122,9 @@ object Common {
     ),
     // Test dependencies
     libraryDependencies ++= Seq(
-      "org.scalatest" %% "scalatest" % "2.2.6" % "test", // Apache v2
-      "org.mockito" % "mockito-all" % "1.10.19" % "test",   // MIT
-      // use the same jackson version in test than the one provided at runtime 
by Spark 2.0.0
-      "com.fasterxml.jackson.core" % "jackson-databind" % "2.6.5" % "test" // 
Apache v2
+      Dependencies.scalaTest % "test",
+      Dependencies.mockito % "test",
+      Dependencies.jacksonDatabind % "test"
     ),
     ScoverageSbtPlugin.ScoverageKeys.coverageHighlighting := false,
     pomExtra :=

http://git-wip-us.apache.org/repos/asf/incubator-toree/blob/bf02de54/protocol/build.sbt
----------------------------------------------------------------------
diff --git a/protocol/build.sbt b/protocol/build.sbt
index 097eccd..ca70698 100644
--- a/protocol/build.sbt
+++ b/protocol/build.sbt
@@ -19,10 +19,10 @@
 // JSON DEPENDENCIES
 //
 libraryDependencies ++= Seq(
-  "com.typesafe.play" %% "play-json" % "2.3.10" excludeAll( // Apache v2
-      ExclusionRule(organization = "com.fasterxml.jackson.core")
-    ),
-  "org.slf4j" % "slf4j-api" % "1.7.21" // MIT
+  Dependencies.playJson excludeAll(
+    ExclusionRule(organization = "com.fasterxml.jackson.core")
+  ),
+  Dependencies.slf4jApi
 )
 
 //

Reply via email to