You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by ew...@apache.org on 2016/01/11 23:17:16 UTC

kafka git commit: KAFKA-3021: Centralize dependency version management

Repository: kafka
Updated Branches:
  refs/heads/trunk 9c998dd8c -> f009c3094


KAFKA-3021: Centralize dependency version management

Author: Grant Henke <gr...@gmail.com>

Reviewers: Ewen Cheslack-Postava <ew...@confluent.io>

Closes #741 from granthenke/central-deps


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

Branch: refs/heads/trunk
Commit: f009c30947c49fec4f41efcc31b9d5d72b6f7f37
Parents: 9c998dd
Author: Grant Henke <gr...@gmail.com>
Authored: Mon Jan 11 14:16:58 2016 -0800
Committer: Ewen Cheslack-Postava <me...@ewencp.org>
Committed: Mon Jan 11 14:16:58 2016 -0800

----------------------------------------------------------------------
 build.gradle               | 163 +++++++++++++++++++---------------------
 gradle/dependencies.gradle |  93 +++++++++++++++++++++++
 scala.gradle               |  41 ----------
 settings.gradle            |   1 -
 4 files changed, 171 insertions(+), 127 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/f009c309/build.gradle
----------------------------------------------------------------------
diff --git a/build.gradle b/build.gradle
index a481280..150cac7 100644
--- a/build.gradle
+++ b/build.gradle
@@ -27,17 +27,6 @@ buildscript {
   }
 }
 
-def slf4jlog4j='org.slf4j:slf4j-log4j12:1.7.6'
-def slf4japi="org.slf4j:slf4j-api:1.7.6"
-def junit='junit:junit:4.12'
-def easymock='org.easymock:easymock:3.4'
-def powermock='org.powermock:powermock-module-junit4:1.6.3'
-def powermock_easymock='org.powermock:powermock-api-easymock:1.6.3'
-def jackson_version = '2.6.3'
-def jetty_version = '9.2.14.v20151106'
-def jersey_version = '2.22.1'
-def reflections_version = '0.9.10'
-
 allprojects {
   apply plugin: 'idea'
   apply plugin: 'eclipse'
@@ -63,8 +52,8 @@ ext {
 
 }
 
+apply from: "$rootDir/gradle/dependencies.gradle"
 apply from: file('wrapper.gradle')
-apply from: file('scala.gradle')
 
 if (new File('.git').exists()) {
   apply from: file('gradle/rat.gradle')
@@ -289,31 +278,30 @@ tasks.create(name: "releaseTarGzAll", dependsOn: ['releaseTarGz_2_10', 'releaseT
 tasks.create(name: "uploadArchivesAll", dependsOn: ['uploadCoreArchives_2_10', 'uploadCoreArchives_2_11'] + pkgs.collect { it + ":uploadArchives" }) { }
 
 project(':core') {
-  println "Building project 'core' with Scala version $resolvedScalaVersion"
+  println "Building project 'core' with Scala version ${versions.scala}"
 
   apply plugin: 'scala'
-  archivesBaseName = "kafka_${baseScalaVersion}"
+  archivesBaseName = "kafka_${versions.baseScala}"
 
   dependencies {
     compile project(':clients')
-    compile "$slf4jlog4j"
-    compile "org.scala-lang:scala-library:$resolvedScalaVersion"
-    compile 'org.apache.zookeeper:zookeeper:3.4.6'
-    compile 'com.101tec:zkclient:0.7'
-    compile 'com.yammer.metrics:metrics-core:2.2.0'
-    compile 'net.sf.jopt-simple:jopt-simple:4.9'
-    if (baseScalaVersion == '2.11') {
-      compile 'org.scala-lang.modules:scala-parser-combinators_2.11:1.0.4'
+    compile libs.joptSimple
+    compile libs.metrics
+    compile libs.scala
+    compile libs.slf4jlog4j
+    compile libs.zkclient
+    compile libs.zookeeper
+    // These modules were broken out of core scala in 2.10. We can remove special handling when 2.10 support is dropped.
+    if (versions.baseScala != '2.10') {
+      compile libs.scalaParserCombinators
     }
 
-    testCompile "$junit"
-    testCompile "$easymock"
-    testCompile 'org.bouncycastle:bcpkix-jdk15on:1.53'
-    testCompile "org.scalatest:scalatest_$baseScalaVersion:2.2.5"
-    testCompile project(':clients')
     testCompile project(':clients').sourceSets.test.output
-    testCompile 'org.apache.hadoop:hadoop-minikdc:2.7.1'
-    testRuntime "$slf4jlog4j"
+    testCompile libs.bcpkix
+    testCompile libs.easymock
+    testCompile libs.hadoopMiniKdc
+    testCompile libs.junit
+    testCompile libs.scalaTest
   }
 
   configurations {
@@ -337,7 +325,7 @@ project(':core') {
     from (configurations.runtime) {
       exclude('kafka-clients*')
     }
-    into "$buildDir/dependant-libs-${resolvedScalaVersion}"
+    into "$buildDir/dependant-libs-${versions.scala}"
   }
 
   tasks.create(name: "genProducerConfigDocs", dependsOn:jar, type: JavaExec) {
@@ -366,7 +354,7 @@ project(':core') {
   }
 
   tasks.create(name: "releaseTarGz", dependsOn: configurations.archives.artifacts, type: Tar) {
-    into "kafka_${baseScalaVersion}-${version}"
+    into "kafka_${versions.baseScala}-${version}"
     compression = Compression.GZIP
     from(project.file("../bin")) { into "bin/" }
     from(project.file("../config")) { into "config/" }
@@ -425,13 +413,14 @@ project(':clients') {
   archivesBaseName = "kafka-clients"
 
   dependencies {
-    compile "$slf4japi"
-    compile 'org.xerial.snappy:snappy-java:1.1.2'
-    compile 'net.jpountz.lz4:lz4:1.3'
+    compile libs.lz4
+    compile libs.snappy
+    compile libs.slf4jApi
+
+    testCompile libs.bcpkix
+    testCompile libs.junit
 
-    testCompile 'org.bouncycastle:bcpkix-jdk15on:1.52'
-    testCompile "$junit"
-    testRuntime "$slf4jlog4j"
+    testRuntime libs.slf4jlog4j
   }
 
   task determineCommitId {
@@ -442,12 +431,12 @@ project(':clients') {
       if (headRef.contains('ref: ')) {
         headRef = headRef.replaceAll('ref: ', '').trim()
         if (file("../.git/$headRef").exists()) {
-          commitId = file("../.git/$headRef").text.trim().take(takeFromHash)
-        } 
+        commitId = file("../.git/$headRef").text.trim().take(takeFromHash)
+        }
       } else {
         commitId = headRef.trim().take(takeFromHash)
       }
-    } 
+    }
     commitId
   }
 
@@ -493,12 +482,12 @@ project(':tools') {
     dependencies {
         compile project(':clients')
         compile project(':log4j-appender')
-        compile 'net.sourceforge.argparse4j:argparse4j:0.5.0'
-        compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version"
-        compile "$slf4jlog4j"
+        compile libs.argparse4j
+        compile libs.jacksonDatabind
+        compile libs.slf4jlog4j
 
-        testCompile "$junit"
-        testCompile project(path: ':clients', configuration: 'archives')
+        testCompile project(':clients')
+        testCompile libs.junit
     }
 
     javadoc {
@@ -512,7 +501,7 @@ project(':tools') {
         from (configurations.runtime) {
             exclude('kafka-clients*')
         }
-        into "$buildDir/dependant-libs-${resolvedScalaVersion}"
+        into "$buildDir/dependant-libs-${versions.scala}"
     }
 
     jar {
@@ -525,13 +514,13 @@ project(':streams') {
 
     dependencies {
         compile project(':clients')
-        compile "$slf4jlog4j"
-        compile 'org.rocksdb:rocksdbjni:3.10.1'
-        compile 'com.101tec:zkclient:0.7' // this dependency should be removed after KIP-4
-        compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version"  // this dependency should be removed after KIP-4
+        compile libs.slf4jlog4j
+        compile libs.rocksDBJni
+        compile libs.zkclient // this dependency should be removed after KIP-4
+        compile libs.jacksonDatabind // this dependency should be removed after KIP-4
 
-        testCompile "$junit"
-        testCompile project(path: ':clients', configuration: 'archives')
+        testCompile project(':clients').sourceSets.test.output
+        testCompile libs.junit
     }
 
     javadoc {
@@ -545,7 +534,7 @@ project(':streams') {
         from (configurations.runtime) {
             exclude('kafka-clients*')
         }
-        into "$buildDir/dependant-libs-${resolvedScalaVersion}"
+        into "$buildDir/dependant-libs-${versions.scala}"
     }
 
     jar {
@@ -558,10 +547,10 @@ project(':log4j-appender') {
 
   dependencies {
     compile project(':clients')
-    compile "$slf4jlog4j"
+    compile libs.slf4jlog4j
 
-    testCompile "$junit"
-    testCompile project(path: ':clients', configuration: 'archives')
+    testCompile project(':clients').sourceSets.test.output
+    testCompile libs.junit
   }
 
   javadoc {
@@ -573,11 +562,12 @@ project(':connect:api') {
   archivesBaseName = "connect-api"
 
   dependencies {
-    compile "$slf4japi"
     compile project(':clients')
+    compile libs.slf4jApi
+
+    testCompile libs.junit
 
-    testCompile "$junit"
-    testRuntime "$slf4jlog4j"
+    testRuntime libs.slf4jlog4j
   }
 
   javadoc {
@@ -605,14 +595,15 @@ project(':connect:json') {
 
   dependencies {
     compile project(':connect:api')
-    compile "$slf4japi"
-    compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version"
+    compile libs.jacksonDatabind
+    compile libs.slf4jApi
 
-    testCompile "$junit"
-    testCompile "$easymock"
-    testCompile "$powermock"
-    testCompile "$powermock_easymock"
-    testRuntime "$slf4jlog4j"
+    testCompile libs.easymock
+    testCompile libs.junit
+    testCompile libs.powermock
+    testCompile libs.powermockEasymock
+
+    testRuntime libs.slf4jlog4j
   }
 
   javadoc {
@@ -642,21 +633,22 @@ project(':connect:runtime') {
     compile project(':connect:api')
     compile project(':clients')
     compile project(':tools')
-    compile "$slf4japi"
-
-    compile "org.eclipse.jetty:jetty-server:$jetty_version"
-    compile "org.eclipse.jetty:jetty-servlet:$jetty_version"
-    compile "com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:$jackson_version"
-    compile "org.glassfish.jersey.containers:jersey-container-servlet:$jersey_version"
-    compile "org.reflections:reflections:$reflections_version"
-
-    testCompile "$junit"
-    testCompile "$easymock"
-    testCompile "$powermock"
-    testCompile "$powermock_easymock"
+    compile libs.slf4jApi
+
+    compile libs.jacksonJaxrsJsonProvider
+    compile libs.jerseyContainerServlet
+    compile libs.jettyServer
+    compile libs.jettyServlet
+    compile libs.reflections
+
     testCompile project(':clients').sourceSets.test.output
-    testRuntime "$slf4jlog4j"
+    testCompile libs.easymock
+    testCompile libs.junit
+    testCompile libs.powermock
+    testCompile libs.powermockEasymock
+
     testRuntime project(":connect:json")
+    testRuntime libs.slf4jlog4j
   }
 
   javadoc {
@@ -690,13 +682,14 @@ project(':connect:file') {
 
   dependencies {
     compile project(':connect:api')
-    compile "$slf4japi"
+    compile libs.slf4jApi
+
+    testCompile libs.easymock
+    testCompile libs.junit
+    testCompile libs.powermock
+    testCompile libs.powermockEasymock
 
-    testCompile "$junit"
-    testCompile "$easymock"
-    testCompile "$powermock"
-    testCompile "$powermock_easymock"
-    testRuntime "$slf4jlog4j"
+    testRuntime libs.slf4jlog4j
   }
 
   javadoc {

http://git-wip-us.apache.org/repos/asf/kafka/blob/f009c309/gradle/dependencies.gradle
----------------------------------------------------------------------
diff --git a/gradle/dependencies.gradle b/gradle/dependencies.gradle
new file mode 100644
index 0000000..d0ce616
--- /dev/null
+++ b/gradle/dependencies.gradle
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+ext {
+  versions = [:]
+  libs = [:]
+}
+
+versions += [
+  argparse4j: "0.5.0",
+  bcpkix: "1.53",
+  hadoop: "2.7.1",
+  easymock: "3.4",
+  jackson: "2.6.3",
+  jetty: "9.2.14.v20151106",
+  jersey: "2.22.1",
+  jopt: "4.9",
+  junit: "4.12",
+  lz4: "1.3.0",
+  metrics: "2.2.0",
+  powermock: "1.6.3",
+  reflections: "0.9.10",
+  rocksDB: "3.10.1",
+  scalaTest: "2.2.5",
+  scalaParserCombinators: "1.0.4",
+  slf4j: "1.7.6",
+  snappy: "1.1.2",
+  zkclient: "0.7",
+  zookeeper: "3.4.6",
+]
+
+// Add Scala version
+def defaultScala210Version = '2.10.6'
+def defaultScala211Version = '2.11.7'
+if (hasProperty('scalaVersion')) {
+  if (scalaVersion == '2.10') {
+    versions["scala"] = defaultScala210Version
+  } else if (scalaVersion == '2.11') {
+    versions["scala"] = defaultScala211Version
+  } else {
+    versions["scala"] = scalaVersion
+  }
+} else {
+  versions["scala"] = defaultScala210Version
+}
+
+// Add base Scala version
+versions["baseScala"] = versions.scala.substring(0, versions.scala.lastIndexOf("."))
+
+libs += [
+  argparse4j: "net.sourceforge.argparse4j:argparse4j:$versions.argparse4j",
+  bcpkix: "org.bouncycastle:bcpkix-jdk15on:$versions.bcpkix",
+  hadoopMiniKdc: "org.apache.hadoop:hadoop-minikdc:$versions.hadoop",
+  easymock: "org.easymock:easymock:$versions.easymock",
+  jacksonDatabind: "com.fasterxml.jackson.core:jackson-databind:$versions.jackson",
+  jacksonJaxrsJsonProvider: "com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:$versions.jackson",
+  jettyServer: "org.eclipse.jetty:jetty-server:$versions.jetty",
+  jettyServlet: "org.eclipse.jetty:jetty-servlet:$versions.jetty",
+  jerseyContainerServlet: "org.glassfish.jersey.containers:jersey-container-servlet:$versions.jersey",
+  junit: "junit:junit:$versions.junit",
+  joptSimple: "net.sf.jopt-simple:jopt-simple:$versions.jopt",
+  lz4: "net.jpountz.lz4:lz4:$versions.lz4",
+  metrics: "com.yammer.metrics:metrics-core:$versions.metrics",
+  powermock: "org.powermock:powermock-module-junit4:$versions.powermock",
+  powermockEasymock: "org.powermock:powermock-api-easymock:$versions.powermock",
+  reflections: "org.reflections:reflections:$versions.reflections",
+  rocksDBJni: "org.rocksdb:rocksdbjni:$versions.rocksDB",
+  scala: "org.scala-lang:scala-library:$versions.scala",
+  scalaCompiler: "org.scala-lang:scala-compiler:$versions.scala",
+  scalaTest: "org.scalatest:scalatest_$versions.baseScala:$versions.scalaTest",
+  scalaParserCombinators: "org.scala-lang.modules:scala-parser-combinators_$versions.baseScala:$versions.scalaParserCombinators",
+  slf4jApi: "org.slf4j:slf4j-api:$versions.slf4j",
+  slf4jlog4j: "org.slf4j:slf4j-log4j12:$versions.slf4j",
+  snappy: "org.xerial.snappy:snappy-java:$versions.snappy",
+  zkclient: "com.101tec:zkclient:$versions.zkclient",
+  zookeeper: "org.apache.zookeeper:zookeeper:$versions.zookeeper"
+]

http://git-wip-us.apache.org/repos/asf/kafka/blob/f009c309/scala.gradle
----------------------------------------------------------------------
diff --git a/scala.gradle b/scala.gradle
deleted file mode 100644
index e33a94f..0000000
--- a/scala.gradle
+++ /dev/null
@@ -1,41 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one or more
-// contributor license agreements.  See the NOTICE file distributed with
-// this work for additional information regarding copyright ownership.
-// The ASF licenses this file to You under the Apache License, Version 2.0
-// (the "License"); you may not use this file except in compliance with
-// the License.  You may obtain a copy of the License at
-//
-//    http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-ext.defaultScala210Version = '2.10.6'
-ext.defaultScala211Version = '2.11.7'
-if (!hasProperty('scalaVersion')) {
-  ext.scalaVersion = defaultScala210Version
-}
-ext.defaultScalaVersion = defaultScala210Version
-
-if (scalaVersion.startsWith('2.10')) {
-    ext.baseScalaVersion = '2.10'
-    setResolvedScalaVersion(defaultScala210Version)
-} else if (scalaVersion.startsWith('2.11')) {
-    ext.baseScalaVersion = '2.11'
-    setResolvedScalaVersion(defaultScala211Version)
-} else {
-    ext.baseScalaVersion = scalaVersion
-}
-
-def setResolvedScalaVersion(defaultFullScalaVersion) {
-    if (scalaVersion == ext.baseScalaVersion) {
-        ext.resolvedScalaVersion = defaultFullScalaVersion
-    }
-    else {
-        ext.resolvedScalaVersion = scalaVersion
-    }
-}
-

http://git-wip-us.apache.org/repos/asf/kafka/blob/f009c309/settings.gradle
----------------------------------------------------------------------
diff --git a/settings.gradle b/settings.gradle
index 3d69fac..097c43b 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -13,6 +13,5 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-apply from: file('scala.gradle')
 include 'core', 'examples', 'clients', 'tools', 'streams', 'log4j-appender',
         'connect:api', 'connect:runtime', 'connect:json', 'connect:file'