Skip to content

Commit

Permalink
Fix gradle grpc protoc project local dependency sequencing (#1727)
Browse files Browse the repository at this point in the history
Motivation:
servicetalk-grpc-protoc has tests in the local directory that depend
upon the compileJava task to complete and the buildExecutable task to
complete. However the dynamically generated generateTestProto task
didn't have an explicit ordering/sequencing dependency on the
buildExecutable task so the build would occasionally fail due to lack of
grpc-protoc artifact.

Modifications:
- Add an explicit dependency from the generateTestProto task on the
  buildExecutable task
- Use a consistent strategy to specify the dependency for other
  sub-projects in the same gradle projects.

Result:
No more spurious build failures due to missing grpc-protoc artifacts.
  • Loading branch information
Scottmitch authored and idelpivnitskiy committed Aug 17, 2021
1 parent 8f9e68d commit ae838ce
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 67 deletions.
20 changes: 10 additions & 10 deletions servicetalk-examples/grpc/compression/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,21 @@ protobuf {
}
plugins {
servicetalk_grpc {
//// Users are expected to use "artifact" instead of "path". we use "path"
//// only because we want to use the gradle project local version of the plugin
// artifact = "io.servicetalk:servicetalk-grpc-protoc:$serviceTalkVersion:all@jar"
//// REMOVE if outside of ServiceTalk gradle project - use "artifact" as demonstrated below
//// "path" is used only because we want to use the gradle project local version of the plugin.
path = file("${project.rootProject.rootDir}/servicetalk-grpc-protoc/build" +
"/buildExecutable/servicetalk-grpc-protoc-${project.version}-all.jar").path
"/buildExecutable/servicetalk-grpc-protoc-${project.version}-all.jar").path
//// REMOVE if outside of ServiceTalk gradle project - use "artifact" as demonstrated below

// artifact = "io.servicetalk:servicetalk-grpc-protoc:$serviceTalkVersion:all@jar"
}
}
generateProtoTasks {
all().each { task ->
//// REMOVE if outside of ServiceTalk gradle project
task.dependsOn(":servicetalk-grpc-protoc:buildExecutable") // use gradle project local grpc-protoc dependency
//// REMOVE if outside of ServiceTalk gradle project

task.plugins {
servicetalk_grpc {
// Need to tell protobuf-gradle-plugin to output in the correct directory if all generated
Expand All @@ -61,9 +67,3 @@ protobuf {
}
generatedFilesBaseDir = "$buildDir/generated/sources/proto"
}

// The following setting must be omitted in users projects and is necessary here
// only because we want to use the locally built version of the plugin
afterEvaluate {
generateProto.dependsOn(":servicetalk-grpc-protoc:buildExecutable")
}
20 changes: 10 additions & 10 deletions servicetalk-examples/grpc/deadline/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,21 @@ protobuf {
}
plugins {
servicetalk_grpc {
//// Users are expected to use "artifact" instead of "path". we use "path"
//// only because we want to use the gradle project local version of the plugin
// artifact = "io.servicetalk:servicetalk-grpc-protoc:$serviceTalkVersion:all@jar"
//// REMOVE if outside of ServiceTalk gradle project - use "artifact" as demonstrated below
//// "path" is used only because we want to use the gradle project local version of the plugin.
path = file("${project.rootProject.rootDir}/servicetalk-grpc-protoc/build" +
"/buildExecutable/servicetalk-grpc-protoc-${project.version}-all.jar").path
"/buildExecutable/servicetalk-grpc-protoc-${project.version}-all.jar").path
//// REMOVE if outside of ServiceTalk gradle project - use "artifact" as demonstrated below

// artifact = "io.servicetalk:servicetalk-grpc-protoc:$serviceTalkVersion:all@jar"
}
}
generateProtoTasks {
all().each { task ->
//// REMOVE if outside of ServiceTalk gradle project
task.dependsOn(":servicetalk-grpc-protoc:buildExecutable") // use gradle project local grpc-protoc dependency
//// REMOVE if outside of ServiceTalk gradle project

task.plugins {
servicetalk_grpc {
// Need to tell protobuf-gradle-plugin to output in the correct directory if all generated
Expand All @@ -59,9 +65,3 @@ protobuf {
}
generatedFilesBaseDir = "$buildDir/generated/sources/proto"
}

// The following setting must be omitted in users projects and is necessary here
// only because we want to use the locally built version of the plugin
afterEvaluate {
generateProto.dependsOn(":servicetalk-grpc-protoc:buildExecutable")
}
20 changes: 10 additions & 10 deletions servicetalk-examples/grpc/errors/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,21 @@ protobuf {
}
plugins {
servicetalk_grpc {
//// Users are expected to use "artifact" instead of "path". we use "path"
//// only because we want to use the gradle project local version of the plugin
// artifact = "io.servicetalk:servicetalk-grpc-protoc:$serviceTalkVersion:all@jar"
//// REMOVE if outside of ServiceTalk gradle project - use "artifact" as demonstrated below
//// "path" is used only because we want to use the gradle project local version of the plugin.
path = file("${project.rootProject.rootDir}/servicetalk-grpc-protoc/build" +
"/buildExecutable/servicetalk-grpc-protoc-${project.version}-all.jar").path
"/buildExecutable/servicetalk-grpc-protoc-${project.version}-all.jar").path
//// REMOVE if outside of ServiceTalk gradle project - use "artifact" as demonstrated below

// artifact = "io.servicetalk:servicetalk-grpc-protoc:$serviceTalkVersion:all@jar"
}
}
generateProtoTasks {
all().each { task ->
//// REMOVE if outside of ServiceTalk gradle project
task.dependsOn(":servicetalk-grpc-protoc:buildExecutable") // use gradle project local grpc-protoc dependency
//// REMOVE if outside of ServiceTalk gradle project

task.plugins {
servicetalk_grpc {
// Need to tell protobuf-gradle-plugin to output in the correct directory if all generated
Expand All @@ -60,9 +66,3 @@ protobuf {
}
generatedFilesBaseDir = "$buildDir/generated/sources/proto"
}

// The following setting must be omitted in users projects and is necessary here
// only because we want to use the locally built version of the plugin
afterEvaluate {
generateProto.dependsOn(":servicetalk-grpc-protoc:buildExecutable")
}
20 changes: 10 additions & 10 deletions servicetalk-examples/grpc/helloworld/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,21 @@ protobuf {
}
plugins {
servicetalk_grpc {
//// Users are expected to use "artifact" instead of "path". we use "path"
//// only because we want to use the gradle project local version of the plugin
// artifact = "io.servicetalk:servicetalk-grpc-protoc:$serviceTalkVersion:all@jar"
//// REMOVE if outside of ServiceTalk gradle project - use "artifact" as demonstrated below
//// "path" is used only because we want to use the gradle project local version of the plugin.
path = file("${project.rootProject.rootDir}/servicetalk-grpc-protoc/build" +
"/buildExecutable/servicetalk-grpc-protoc-${project.version}-all.jar").path
"/buildExecutable/servicetalk-grpc-protoc-${project.version}-all.jar").path
//// REMOVE if outside of ServiceTalk gradle project - use "artifact" as demonstrated below

// artifact = "io.servicetalk:servicetalk-grpc-protoc:$serviceTalkVersion:all@jar"
}
}
generateProtoTasks {
all().each { task ->
//// REMOVE if outside of ServiceTalk gradle project
task.dependsOn(":servicetalk-grpc-protoc:buildExecutable") // use gradle project local grpc-protoc dependency
//// REMOVE if outside of ServiceTalk gradle project

task.plugins {
servicetalk_grpc {
// Need to tell protobuf-gradle-plugin to output in the correct directory if all generated
Expand All @@ -60,9 +66,3 @@ protobuf {
}
generatedFilesBaseDir = "$buildDir/generated/sources/proto"
}

// The following setting must be omitted in users projects and is necessary here
// only because we want to use the locally built version of the plugin
afterEvaluate {
generateProto.dependsOn(":servicetalk-grpc-protoc:buildExecutable")
}
20 changes: 10 additions & 10 deletions servicetalk-examples/grpc/protoc-options/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,21 @@ protobuf {
}
plugins {
servicetalk_grpc {
//// Users are expected to use "artifact" instead of "path". we use "path"
//// only because we want to use the gradle project local version of the plugin
// artifact = "io.servicetalk:servicetalk-grpc-protoc:$serviceTalkVersion:all@jar"
//// REMOVE if outside of ServiceTalk gradle project - use "artifact" as demonstrated below
//// "path" is used only because we want to use the gradle project local version of the plugin.
path = file("${project.rootProject.rootDir}/servicetalk-grpc-protoc/build" +
"/buildExecutable/servicetalk-grpc-protoc-${project.version}-all.jar").path
"/buildExecutable/servicetalk-grpc-protoc-${project.version}-all.jar").path
//// REMOVE if outside of ServiceTalk gradle project - use "artifact" as demonstrated below

// artifact = "io.servicetalk:servicetalk-grpc-protoc:$serviceTalkVersion:all@jar"
}
}
generateProtoTasks {
all().each { task ->
//// REMOVE if outside of ServiceTalk gradle project
task.dependsOn(":servicetalk-grpc-protoc:buildExecutable") // use gradle project local grpc-protoc dependency
//// REMOVE if outside of ServiceTalk gradle project

task.plugins {
servicetalk_grpc {
// Need to tell protobuf-gradle-plugin to output in the correct directory if all generated
Expand All @@ -62,9 +68,3 @@ protobuf {
}
generatedFilesBaseDir = "$buildDir/generated/sources/proto"
}

// The following setting must be omitted in users projects and is necessary here
// only because we want to use the locally built version of the plugin
afterEvaluate {
generateProto.dependsOn(":servicetalk-grpc-protoc:buildExecutable")
}
18 changes: 9 additions & 9 deletions servicetalk-examples/grpc/routeguide/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,21 @@ protobuf {
}
plugins {
servicetalk_grpc {
//// Users are expected to use "artifact" instead of "path". we use "path"
//// only because we want to use the gradle project local version of the plugin
// artifact = "io.servicetalk:servicetalk-grpc-protoc:$serviceTalkVersion:all@jar"
//// REMOVE if outside of ServiceTalk gradle project - use "artifact" as demonstrated below
//// "path" is used only because we want to use the gradle project local version of the plugin.
path = file("${project.rootProject.rootDir}/servicetalk-grpc-protoc/build" +
"/buildExecutable/servicetalk-grpc-protoc-${project.version}-all.jar").path
//// REMOVE if outside of ServiceTalk gradle project - use "artifact" as demonstrated below

// artifact = "io.servicetalk:servicetalk-grpc-protoc:$serviceTalkVersion:all@jar"
}
}
generateProtoTasks {
all().each { task ->
//// REMOVE if outside of ServiceTalk gradle project
task.dependsOn(":servicetalk-grpc-protoc:buildExecutable") // use gradle project local grpc-protoc dependency
//// REMOVE if outside of ServiceTalk gradle project

task.plugins {
servicetalk_grpc {
// Need to tell protobuf-gradle-plugin to output in the correct directory if all generated
Expand All @@ -61,9 +67,3 @@ protobuf {
}
generatedFilesBaseDir = "$buildDir/generated/sources/proto"
}

// The following setting must be omitted in users projects and is necessary here
// only because we want to use the locally built version of the plugin
afterEvaluate {
generateProto.dependsOn(":servicetalk-grpc-protoc:buildExecutable")
}
13 changes: 5 additions & 8 deletions servicetalk-grpc-netty/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,17 @@ protobuf {
artifact = "io.grpc:protoc-gen-grpc-java:$grpcVersion"
}
servicetalk_grpc {
//// Users are expected to use "artifact" instead of "path". we use "path"
//// only because we want to use the gradle project local version of the plugin
// use gradle project local grpc-protoc dependency
path = file("${project.rootProject.rootDir}/servicetalk-grpc-protoc/build" +
"/buildExecutable/servicetalk-grpc-protoc-${project.version}-all.jar").path
}
}
generateProtoTasks {
all().each { task ->
if (task.isTest) {
task.dependsOn(":servicetalk-grpc-protoc:buildExecutable") // use gradle project local grpc-protoc dependency
}

task.plugins {
grpc {}
servicetalk_grpc {
Expand All @@ -93,9 +96,3 @@ protobuf {
}
generatedFilesBaseDir = "$buildDir/generated/sources/proto"
}

//// The following setting must be omitted in users projects and is necessary here
//// only because we want to use the gradle project local version of the plugin
afterEvaluate {
generateTestProto.dependsOn(":servicetalk-grpc-protoc:buildExecutable")
}
4 changes: 4 additions & 0 deletions servicetalk-grpc-protoc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ protobuf {
}
generateProtoTasks {
all().each { task ->
if (task.isTest) {
task.dependsOn(buildExecutable)
}

task.plugins {
servicetalk_grpc {
// Need to tell protobuf-gradle-plugin to output in the correct directory if all generated
Expand Down

0 comments on commit ae838ce

Please sign in to comment.