You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by gr...@apache.org on 2018/08/27 19:32:14 UTC

[3/3] kudu git commit: Add protobuf generated files to Eclipse project classpath.

Add protobuf generated files to Eclipse project classpath.

With this change Eclipse can compile all Kudu Java projects
and can run JUnit tests directly

Change-Id: I825002ce8436467cb9c32c0954f378e1959a5586
Reviewed-on: http://gerrit.cloudera.org:8080/11310
Reviewed-by: Grant Henke <gr...@apache.org>
Tested-by: Grant Henke <gr...@apache.org>


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

Branch: refs/heads/master
Commit: f5ffcb4d7b2ebd2ca134f9a72c396c82ffcb36b4
Parents: 1308db9
Author: Greg Solovyev <gs...@cloudera.com>
Authored: Thu Aug 23 15:37:36 2018 -0700
Committer: Grant Henke <gr...@apache.org>
Committed: Mon Aug 27 19:31:48 2018 +0000

----------------------------------------------------------------------
 java/gradle/protobuf.gradle | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/f5ffcb4d/java/gradle/protobuf.gradle
----------------------------------------------------------------------
diff --git a/java/gradle/protobuf.gradle b/java/gradle/protobuf.gradle
index f3d84bc..5bcabd3 100644
--- a/java/gradle/protobuf.gradle
+++ b/java/gradle/protobuf.gradle
@@ -16,7 +16,7 @@
 // under the License.
 
 // This file contains the common protobuf plugin configuration.
-
+import org.gradle.plugins.ide.eclipse.model.SourceFolder
 apply plugin: "com.google.protobuf"
 
 // Use the maven protoc artifact instead of local.
@@ -31,4 +31,23 @@ idea {
   module {
     generatedSourceDirs += file("${protobuf.generatedFilesBaseDir}/main/java")
   }
-}
\ No newline at end of file
+}
+
+// Configure Eclipse to see the generated classes.
+eclipse {
+  classpath {
+    file {
+      whenMerged {
+         // protobuf.generatedFilesBaseDir contains absolute path to the root project.
+         // Here we have to make the path relative to a subproject,
+         // because Buildship ignores absolute paths when it evaluates classpath entries.
+
+         // Passing 'null' as a second argument to SourceFolder constructor
+         // instructs Eclipse to not compile generated source files
+         def relPath = projectDir.toPath().relativize(
+           file("${protobuf.generatedFilesBaseDir}/main/java").toPath())
+         entries += new SourceFolder(relPath.toString(), null)
+      }
+    }
+  }
+}