kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ij...@apache.org
Subject kafka git commit: KAFKA-4617; Improve configuration of Gradle’s eclipse task
Date Fri, 10 Feb 2017 02:45:38 GMT
Repository: kafka
Updated Branches:
  refs/heads/trunk d24616777 -> b6c34e2df


KAFKA-4617; Improve configuration of Gradle’s eclipse task

Generate core project with correct source folders. In addition
set output folders same as command line build. Don't generate
unnecessary projects.

Author: Dhwani Katagade <dhwani_katagade@persistent.com>

Reviewers: Edoardo Comar <ecomar@uk.ibm.com>, Guozhang Wang <wangguoz@gmail.com>,
Ismael Juma <ismael@juma.me.uk>

Closes #2382 from dhwanikatagade/gradle_eclipse_plugin_path_fix


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

Branch: refs/heads/trunk
Commit: b6c34e2df5dc4e3f6cda9b64786d7e929acb963b
Parents: d246167
Author: Dhwani Katagade <dhwani_katagade@persistent.com>
Authored: Fri Feb 10 02:37:32 2017 +0000
Committer: Ismael Juma <ismael@juma.me.uk>
Committed: Fri Feb 10 02:45:29 2017 +0000

----------------------------------------------------------------------
 README.md    |  4 ++++
 build.gradle | 37 ++++++++++++++++++++++++++++++++++++-
 2 files changed, 40 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/b6c34e2d/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index d55098e..1ae5824 100644
--- a/README.md
+++ b/README.md
@@ -90,6 +90,10 @@ This is for `core`, `examples` and `clients`
     ./gradlew eclipse
     ./gradlew idea
 
+The `eclipse` task has been configured to use `${project_dir}/build_eclipse` as Eclipse's
build directory. Eclipse's default
+build directory (`${project_dir}/bin`) clashes with Kafka's scripts directory and we don't
use Gradle's build directory
+to avoid known issues with this configuration.
+
 ### Building the jar for all scala versions and for all projects ###
     ./gradlew jarAll
 

http://git-wip-us.apache.org/repos/asf/kafka/blob/b6c34e2d/build.gradle
----------------------------------------------------------------------
diff --git a/build.gradle b/build.gradle
index 32ce14a..2006f52 100644
--- a/build.gradle
+++ b/build.gradle
@@ -32,7 +32,6 @@ buildscript {
 
 allprojects {
   apply plugin: 'idea'
-  apply plugin: 'eclipse'
   apply plugin: "jacoco"
 
   repositories {
@@ -117,6 +116,11 @@ if (new File('.git').exists()) {
 
 subprojects {
   apply plugin: 'java'
+  // apply the eclipse plugin only to subprojects that hold code. 'connect' is just a folder.
+  if (!project.name.equals('connect')) {
+    apply plugin: 'eclipse'
+    fineTuneEclipseClasspathFile(eclipse, project)
+  }
   apply plugin: 'maven'
   apply plugin: 'signing'
   apply plugin: 'checkstyle'
@@ -288,6 +292,37 @@ subprojects {
   }
 }
 
+def fineTuneEclipseClasspathFile(eclipse, project) {
+  eclipse.classpath.file {
+    beforeMerged { cp ->
+      cp.entries.clear()
+      // for the core project add the directories defined under test/scala as separate source
directories
+      if (project.name.equals('core')) {
+        cp.entries.add(new org.gradle.plugins.ide.eclipse.model.SourceFolder("src/test/scala/integration",
null))
+        cp.entries.add(new org.gradle.plugins.ide.eclipse.model.SourceFolder("src/test/scala/other",
null))
+        cp.entries.add(new org.gradle.plugins.ide.eclipse.model.SourceFolder("src/test/scala/unit",
null))
+      }
+    }
+    whenMerged { cp ->
+      // for the core project exclude the separate sub-directories defined under test/scala.
These are added as source dirs above
+      if (project.name.equals('core')) {
+        cp.entries.findAll { it.kind == "src" && it.path.equals("src/test/scala")
}*.excludes = ["integration/", "other/", "unit/"]
+      }
+      /* 
+       * Set all eclipse build output to go to 'build_eclipse' directory. This is to ensure
that gradle and eclipse use different 
+       * build output directories, and also avoid using the eclpise default of 'bin' which
clashes with some of our script directories.
+       * https://discuss.gradle.org/t/eclipse-generated-files-should-be-put-in-the-same-place-as-the-gradle-generated-files/6986/2
+       */
+      cp.entries.findAll { it.kind == "output" }*.path = "build_eclipse"
+      /*
+       * Some projects have explicitly added test output dependencies. These are required
for the gradle build but not required
+       * in Eclipse since the dependent projects are added as dependencies. So clean up these
from the generated classpath.
+       */
+      cp.entries.removeAll { it.kind == "lib" && it.path.matches(".*/build/(classes|resources)/test")
}
+    }
+  }
+}
+
 // Aggregates all jacoco results into the root project directory
 task jacocoRootReport(type: org.gradle.testing.jacoco.tasks.JacocoReport) {
   def javaProjects = subprojects.findAll { it.path != ':core' }


Mime
View raw message