Skip to content

Commit

Permalink
KAFKA-3021: Centralize dependency version management
Browse files Browse the repository at this point in the history
Author: Grant Henke <[email protected]>

Reviewers: Ewen Cheslack-Postava <[email protected]>

Closes apache#741 from granthenke/central-deps
  • Loading branch information
granthenke authored and ewencp committed Jan 11, 2016
1 parent 9c998dd commit f009c30
Show file tree
Hide file tree
Showing 4 changed files with 171 additions and 127 deletions.
163 changes: 78 additions & 85 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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')
Expand Down Expand Up @@ -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 {
Expand All @@ -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) {
Expand Down Expand Up @@ -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/" }
Expand Down Expand Up @@ -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 {
Expand All @@ -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
}

Expand Down Expand Up @@ -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 {
Expand All @@ -512,7 +501,7 @@ project(':tools') {
from (configurations.runtime) {
exclude('kafka-clients*')
}
into "$buildDir/dependant-libs-${resolvedScalaVersion}"
into "$buildDir/dependant-libs-${versions.scala}"
}

jar {
Expand All @@ -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 {
Expand All @@ -545,7 +534,7 @@ project(':streams') {
from (configurations.runtime) {
exclude('kafka-clients*')
}
into "$buildDir/dependant-libs-${resolvedScalaVersion}"
into "$buildDir/dependant-libs-${versions.scala}"
}

jar {
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
93 changes: 93 additions & 0 deletions gradle/dependencies.gradle
Original file line number Diff line number Diff line change
@@ -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"
]
Loading

0 comments on commit f009c30

Please sign in to comment.