Skip to content

Commit

Permalink
Always include extract protos in compiled archive (#389)
Browse files Browse the repository at this point in the history
Add a missing dependency on the extract proto task by the processResources
task. This fixes a race that meant sometimes extracted protos were left
out of the final jar.
  • Loading branch information
voidzcy authored Mar 5, 2020
1 parent 4805796 commit 243a581
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ class ProtobufPlugin implements Plugin<Project> {
java { }
}

setupExtractProtosTask(generateProtoTask, sourceSet.name)
Task extractTask = setupExtractProtosTask(generateProtoTask, sourceSet.name)
setupExtractIncludeProtosTask(generateProtoTask, sourceSet.name)

// Include source proto files in the compiled archive, so that proto files from
Expand All @@ -273,6 +273,7 @@ class ProtobufPlugin implements Plugin<Project> {
processResourcesTask.from(generateProtoTask.sourceFiles) {
include '**/*.proto'
}
processResourcesTask.dependsOn(extractTask)
}

/**
Expand Down Expand Up @@ -352,7 +353,7 @@ class ProtobufPlugin implements Plugin<Project> {
* variant may have multiple sourceSets, each of these sourceSets will have
* its own extraction task.
*/
private void setupExtractProtosTask(
private Task setupExtractProtosTask(
GenerateProtoTask generateProtoTask, String sourceSetName) {
String extractProtosTaskName = 'extract' +
Utils.getSourceSetSubstringForTaskNames(sourceSetName) + 'Proto'
Expand All @@ -368,6 +369,7 @@ class ProtobufPlugin implements Plugin<Project> {

linkExtractTaskToGenerateTask(task, generateProtoTask)
generateProtoTask.addSourceFiles(project.fileTree(task.destDir) { include "**/*.proto" })
return task
}

/**
Expand Down

0 comments on commit 243a581

Please sign in to comment.