From 2cdc5e3c4735e511a92033d01daf902c49fcd7cd Mon Sep 17 00:00:00 2001 From: Kun Zhang Date: Mon, 11 May 2015 16:58:28 -0700 Subject: [PATCH] Fix a bug that checked-in generated code are not re-compiled. Since commit 287a27a the ``grpc`` codegen plugin must be explicitly added to the ``plugins`` block of the source set, while it didn't. Remove the generated code before recompiling it to prevent such issue from being missed by tests. --- build.gradle | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/build.gradle b/build.gradle index 215b441201..1e69188163 100644 --- a/build.gradle +++ b/build.gradle @@ -46,6 +46,7 @@ subprojects { protobufVersion = '3.0.0-alpha-2' configureProtoCompilation = { + String generatedSourcePath = 'src/generated' if (rootProject.childProjects.containsKey('grpc-compiler')) { // Only when the codegen is built along with the project, will we be able to recompile // the proto files. @@ -61,17 +62,24 @@ subprojects { // it's possible the version of protoc has been changed. generateProto.inputs.file "${rootProject.projectDir}/build.gradle" } + // Delete the generated sources first, so that we can be alerted if they are not re-compiled. + project.delete project.fileTree(dir: generatedSourcePath) + + project.sourceSets { + main { + proto { + plugins { + grpc { } + } + } + } + } } else { // Otherwise, we just use the checked-in generated code. project.sourceSets { main { java { - srcDir 'src/generated/main' - } - proto { - plugins { - grpc { } - } + srcDir "${generatedSourcePath}/main" } } }