Skip to content

Commit 3493132

Browse files
committed
Avoid eagerly resolving the configuration
Calling task.source.isEmpty does some sort of eager resolution of the configurations that were added to the task source. This in turn can trigger other actions within Gradle and cause weird behaviour (in our case, it caused other plugins to get applied and eventually tripped a mutation guard. The wire rootset code has a isEmpty flag it keeps which, according to the comments, is there explicitly to avoid resolving the configuration, so we can use that instead.
1 parent cb4cfd7 commit 3493132

File tree

1 file changed

+6
-1
lines changed
  • wire-gradle-plugin/src/main/kotlin/com/squareup/wire/gradle

1 file changed

+6
-1
lines changed

wire-gradle-plugin/src/main/kotlin/com/squareup/wire/gradle/WirePlugin.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,13 +186,18 @@ class WirePlugin : Plugin<Project> {
186186
task.group = GROUP
187187
task.description = "Generate protobuf implementation for ${source.name}"
188188

189+
var addedSourcesDependencies = false
189190
// Flatten all the input files here. Changes to any of them will cause the task to re-run.
190191
for (rootSet in protoSourceProtoRootSets) {
191192
task.source(rootSet.configuration)
193+
if (!rootSet.isEmpty) {
194+
// Use the isEmpty flag to avoid resolving the configuration eagerly
195+
addedSourcesDependencies = true
196+
}
192197
}
193198
// We only want to add ProtoPath sources if we have other sources already. The WireTask
194199
// would otherwise run even through we have no sources.
195-
if (!task.source.isEmpty) {
200+
if (addedSourcesDependencies) {
196201
for (rootSet in protoPathProtoRootSets) {
197202
task.source(rootSet.configuration)
198203
}

0 commit comments

Comments
 (0)