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/07 01:19:57 UTC

kafka git commit: KAFKA-3022: Deduplicate common project configurations

Repository: kafka
Updated Branches:
  refs/heads/trunk 00114dae7 -> 991cafe4d


KAFKA-3022: Deduplicate common project configurations

- Move testJar to subprojects config
- Move CheckStyle to subprojects config
- Move testLogging to subprojects config
- Add testSourceJar in subprojects config
- Minor cleanup

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

Reviewers: Dong Lin <li...@gmail.com>, Ewen Cheslack-Postava <ew...@confluent.io>

Closes #712 from granthenke/build-dedupe


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

Branch: refs/heads/trunk
Commit: 991cafe4d4d1875ce40c31fbb54ba3930a826e62
Parents: 00114da
Author: Grant Henke <gr...@gmail.com>
Authored: Wed Jan 6 16:19:39 2016 -0800
Committer: Ewen Cheslack-Postava <me...@ewencp.org>
Committed: Wed Jan 6 16:19:39 2016 -0800

----------------------------------------------------------------------
 build.gradle | 275 ++++++++----------------------------------------------
 1 file changed, 37 insertions(+), 238 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/991cafe4/build.gradle
----------------------------------------------------------------------
diff --git a/build.gradle b/build.gradle
index 181e7b1..7be82e8 100644
--- a/build.gradle
+++ b/build.gradle
@@ -40,6 +40,7 @@ def reflections_version = '0.9.10'
 
 allprojects {
   apply plugin: 'idea'
+  apply plugin: 'eclipse'
   repositories {
     mavenCentral()
   }
@@ -83,9 +84,9 @@ if (new File('.git').exists()) {
 
 subprojects {
   apply plugin: 'java'
-  apply plugin: 'eclipse'
   apply plugin: 'maven'
   apply plugin: 'signing'
+  apply plugin: 'checkstyle'
 
   sourceCompatibility = 1.7
 
@@ -129,8 +130,12 @@ subprojects {
     }
   }
 
-  tasks.withType(Test) {
+  test {
     maxParallelForks = userMaxForks ?: Runtime.runtime.availableProcessors()
+    testLogging {
+      events "passed", "skipped", "failed"
+      exceptionFormat = 'full'
+    }
   }
 
   jar {
@@ -138,11 +143,11 @@ subprojects {
     from '../NOTICE'
   }
 
-  task srcJar(type:Jar) {
+  task srcJar(type: Jar) {
     classifier = 'sources'
     from '../LICENSE'
     from '../NOTICE'
-    from sourceSets.main.java
+    from sourceSets.main.allSource
   }
 
   task javadocJar(type: Jar, dependsOn: javadoc) {
@@ -161,15 +166,33 @@ subprojects {
     archives javadocJar
   }
 
-  plugins.withType(ScalaPlugin) {
-    //source jar should also contain scala source:
-    srcJar.from sourceSets.main.scala
+  if(!sourceSets.test.allSource.isEmpty()) {
+    task testJar(type: Jar) {
+      classifier = 'test'
+      from '../LICENSE'
+      from '../NOTICE'
+      from sourceSets.test.output
+    }
+
+    task testSrcJar(type: Jar, dependsOn: testJar) {
+      classifier = 'test-sources'
+      from '../LICENSE'
+      from '../NOTICE'
+      from sourceSets.test.allSource
+    }
+
+    artifacts {
+      archives testJar
+      archives testSrcJar
+    }
+  }
 
+  plugins.withType(ScalaPlugin) {
     task scaladocJar(type:Jar) {
       classifier = 'scaladoc'
       from '../LICENSE'
       from '../NOTICE'
-      from scaladoc
+      from scaladoc.destinationDir
     }
 
     //documentation task should also trigger building scala doc jar
@@ -188,6 +211,12 @@ subprojects {
       jvmArgs = ['-XX:MaxPermSize=512m', '-Xss2m']
     }
   }
+
+  checkstyle {
+    configFile = new File(rootDir, "checkstyle/checkstyle.xml")
+    configProperties = [importControlFile: "$rootDir/checkstyle/import-control.xml"]
+  }
+  test.dependsOn('checkstyleMain', 'checkstyleTest')
 }
 
 for ( sv in ['2_10', '2_11'] ) {
@@ -259,7 +288,6 @@ project(':core') {
   println "Building project 'core' with Scala version $resolvedScalaVersion"
 
   apply plugin: 'scala'
-  apply plugin: 'checkstyle'
   archivesBaseName = "kafka_${baseScalaVersion}"
 
   dependencies {
@@ -365,22 +393,6 @@ project(':core') {
     )
   }
 
-  task testJar(type: Jar) {
-    classifier = 'test'
-    from sourceSets.test.output
-  }
-
-  test {
-    testLogging {
-        events "passed", "skipped", "failed"
-        exceptionFormat = 'full'
-    }
-  }
-
-  artifacts {
-    archives testJar
-  }
-
   tasks.create(name: "copyDependantTestLibs", type: Copy) {
     from (configurations.testRuntime) {
       include('*.jar')
@@ -389,14 +401,11 @@ project(':core') {
   }
 
   checkstyle {
-    configFile = new File(rootDir, "checkstyle/checkstyle.xml")
     configProperties = [importControlFile: "$rootDir/checkstyle/import-control-core.xml"]
   }
-  test.dependsOn('checkstyleMain', 'checkstyleTest')
 }
 
 project(':examples') {
-  apply plugin: 'checkstyle'
   archivesBaseName = "kafka-examples"
 
   dependencies {
@@ -404,14 +413,11 @@ project(':examples') {
   }
 
   checkstyle {
-    configFile = new File(rootDir, "checkstyle/checkstyle.xml")
     configProperties = [importControlFile: "$rootDir/checkstyle/import-control-core.xml"]
   }
-  test.dependsOn('checkstyleMain', 'checkstyleTest')
 }
 
 project(':clients') {
-  apply plugin: 'checkstyle'
   archivesBaseName = "kafka-clients"
 
   dependencies {
@@ -468,18 +474,6 @@ project(':clients') {
     delete "$buildDir/kafka/"
   }
 
-  task testJar(type: Jar) {
-    classifier = 'test'
-    from sourceSets.test.output
-  }
-
-  test {
-    testLogging {
-        events "passed", "skipped", "failed"
-        exceptionFormat = 'full'
-    }
-  }
-
   javadoc {
     include "**/org/apache/kafka/clients/consumer/*"
     include "**/org/apache/kafka/clients/producer/*"
@@ -487,24 +481,9 @@ project(':clients') {
     include "**/org/apache/kafka/common/errors/*"
     include "**/org/apache/kafka/common/serialization/*"
   }
-
-  artifacts {
-    archives testJar
-  }
-
-  configurations {
-    archives.extendsFrom (testCompile)
-  }
-
-  checkstyle {
-     configFile = new File(rootDir, "checkstyle/checkstyle.xml")
-     configProperties = [importControlFile: "$rootDir/checkstyle/import-control.xml"]
-  }
-  test.dependsOn('checkstyleMain', 'checkstyleTest')
 }
 
 project(':tools') {
-    apply plugin: 'checkstyle'
     archivesBaseName = "kafka-tools"
 
     dependencies {
@@ -518,18 +497,6 @@ project(':tools') {
         testCompile project(path: ':clients', configuration: 'archives')
     }
 
-    task testJar(type: Jar) {
-        classifier = 'test'
-        from sourceSets.test.output
-    }
-
-    test {
-        testLogging {
-            events "passed", "skipped", "failed"
-            exceptionFormat = 'full'
-        }
-    }
-
     javadoc {
         include "**/org/apache/kafka/tools/*"
     }
@@ -547,24 +514,9 @@ project(':tools') {
     jar {
         dependsOn 'copyDependantLibs'
     }
-
-    artifacts {
-        archives testJar
-    }
-
-    configurations {
-        archives.extendsFrom (testCompile)
-    }
-
-    checkstyle {
-        configFile = new File(rootDir, "checkstyle/checkstyle.xml")
-        configProperties = [importControlFile: "$rootDir/checkstyle/import-control.xml"]
-    }
-    test.dependsOn('checkstyleMain', 'checkstyleTest')
 }
 
 project(':streams') {
-    apply plugin: 'checkstyle'
     archivesBaseName = "kafka-streams"
 
     dependencies {
@@ -578,18 +530,6 @@ project(':streams') {
         testCompile project(path: ':clients', configuration: 'archives')
     }
 
-    task testJar(type: Jar) {
-        classifier = 'test'
-        from sourceSets.test.output
-    }
-
-    test {
-        testLogging {
-            events "passed", "skipped", "failed"
-            exceptionFormat = 'full'
-        }
-    }
-
     javadoc {
         include "**/org/apache/kafka/streams/*"
     }
@@ -607,24 +547,9 @@ project(':streams') {
     jar {
         dependsOn 'copyDependantLibs'
     }
-
-    artifacts {
-      archives testJar
-    }
-
-    configurations {
-      archives.extendsFrom (testCompile)
-    }
-
-    checkstyle {
-        configFile = new File(rootDir, "checkstyle/checkstyle.xml")
-        configProperties = [importControlFile: "$rootDir/checkstyle/import-control.xml"]
-    }
-    test.dependsOn('checkstyleMain', 'checkstyleTest')
 }
 
 project(':log4j-appender') {
-  apply plugin: 'checkstyle'
   archivesBaseName = "kafka-log4j-appender"
 
   dependencies {
@@ -635,31 +560,12 @@ project(':log4j-appender') {
     testCompile project(path: ':clients', configuration: 'archives')
   }
 
-  task testJar(type: Jar) {
-    classifier = 'test'
-    from sourceSets.test.output
-  }
-
-  test {
-    testLogging {
-        events "passed", "skipped", "failed"
-        exceptionFormat = 'full'
-    }
-  }
-
   javadoc {
     include "**/org/apache/kafka/log4jappender/*"
   }
-
-  checkstyle {
-     configFile = new File(rootDir, "checkstyle/checkstyle.xml")
-     configProperties = [importControlFile: "$rootDir/checkstyle/import-control.xml"]
-  }
-  test.dependsOn('checkstyleMain', 'checkstyleTest')
 }
 
 project(':connect:api') {
-  apply plugin: 'checkstyle'
   archivesBaseName = "connect-api"
 
   dependencies {
@@ -670,18 +576,6 @@ project(':connect:api') {
     testRuntime "$slf4jlog4j"
   }
 
-  task testJar(type: Jar) {
-    classifier = 'test'
-    from sourceSets.test.output
-  }
-
-  test {
-    testLogging {
-      events "passed", "skipped", "failed"
-      exceptionFormat = 'full'
-    }
-  }
-
   javadoc {
     options.links "http://docs.oracle.com/javase/7/docs/api/"
   }
@@ -700,24 +594,9 @@ project(':connect:api') {
   jar {
     dependsOn copyDependantLibs
   }
-
-  artifacts {
-    archives testJar
-  }
-
-  configurations {
-    archives.extendsFrom (testCompile)
-  }
-
-  checkstyle {
-    configFile = new File(rootDir, "checkstyle/checkstyle.xml")
-    configProperties = [importControlFile: "$rootDir/checkstyle/import-control.xml"]
-  }
-  test.dependsOn('checkstyleMain', 'checkstyleTest')
 }
 
 project(':connect:json') {
-  apply plugin: 'checkstyle'
   archivesBaseName = "connect-json"
 
   dependencies {
@@ -732,18 +611,6 @@ project(':connect:json') {
     testRuntime "$slf4jlog4j"
   }
 
-  task testJar(type: Jar) {
-    classifier = 'test'
-    from sourceSets.test.output
-  }
-
-  test {
-    testLogging {
-      events "passed", "skipped", "failed"
-      exceptionFormat = 'full'
-    }
-  }
-
   javadoc {
     enabled = false
   }
@@ -762,24 +629,9 @@ project(':connect:json') {
   jar {
     dependsOn copyDependantLibs
   }
-
-  artifacts {
-    archives testJar
-  }
-
-  configurations {
-    archives.extendsFrom(testCompile)
-  }
-
-  checkstyle {
-    configFile = new File(rootDir, "checkstyle/checkstyle.xml")
-    configProperties = [importControlFile: "$rootDir/checkstyle/import-control.xml"]
-  }
-  test.dependsOn('checkstyleMain', 'checkstyleTest')
 }
 
 project(':connect:runtime') {
-  apply plugin: 'checkstyle'
   archivesBaseName = "connect-runtime"
 
   dependencies {
@@ -803,18 +655,6 @@ project(':connect:runtime') {
     testRuntime project(":connect:json")
   }
 
-  task testJar(type: Jar) {
-    classifier = 'test'
-    from sourceSets.test.output
-  }
-
-  test {
-    testLogging {
-      events "passed", "skipped", "failed"
-      exceptionFormat = 'full'
-    }
-  }
-
   javadoc {
     enabled = false
   }
@@ -834,20 +674,6 @@ project(':connect:runtime') {
     dependsOn copyDependantLibs
   }
 
-  artifacts {
-    archives testJar
-  }
-
-  configurations {
-    archives.extendsFrom(testCompile)
-  }
-
-  checkstyle {
-    configFile = new File(rootDir, "checkstyle/checkstyle.xml")
-    configProperties = [importControlFile: "$rootDir/checkstyle/import-control.xml"]
-  }
-  test.dependsOn('checkstyleMain', 'checkstyleTest')
-
   tasks.create(name: "genConnectConfigDocs", dependsOn:jar, type: JavaExec) {
     classpath = sourceSets.main.runtimeClasspath
     main = 'org.apache.kafka.connect.runtime.distributed.DistributedConfig'
@@ -856,7 +682,6 @@ project(':connect:runtime') {
 }
 
 project(':connect:file') {
-  apply plugin: 'checkstyle'
   archivesBaseName = "connect-file"
 
   dependencies {
@@ -870,18 +695,6 @@ project(':connect:file') {
     testRuntime "$slf4jlog4j"
   }
 
-  task testJar(type: Jar) {
-    classifier = 'test'
-    from sourceSets.test.output
-  }
-
-  test {
-    testLogging {
-      events "passed", "skipped", "failed"
-      exceptionFormat = 'full'
-    }
-  }
-
   javadoc {
     enabled = false
   }
@@ -900,18 +713,4 @@ project(':connect:file') {
   jar {
     dependsOn copyDependantLibs
   }
-
-  artifacts {
-    archives testJar
-  }
-
-  configurations {
-    archives.extendsFrom(testCompile)
-  }
-
-  checkstyle {
-    configFile = new File(rootDir, "checkstyle/checkstyle.xml")
-    configProperties = [importControlFile: "$rootDir/checkstyle/import-control.xml"]
-  }
-  test.dependsOn('checkstyleMain', 'checkstyleTest')
 }