Why does the WorkerExecutor in a task need to be public

Hello! I was wondering, why does the WorkerExecutor in a task need to be public? If it is private, the following error occurs:

> Task :plantUml FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':plantUml'.
> Could not get unknown property 'workerExecutor' for object of type org.gradle.api.internal.changedetection.changes.RebuildIncrementalTaskInputs$RebuildInputFile.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

1 actionable task: 1 executed

The code that generates that error can be found here (you have to make that private): https://github.com/cosminpolifronie/gradle-plantuml-plugin/blob/2a1de394453653d20010e7119cfb56dabe6d0cac/src/main/groovy/de/gafertp/plantuml/PlantUmlTask.groovy#L17

In Groovy there is more going on than what you might be used to in Java. Private fields do not have generated property accessor methods and that means the property will not be accessible from a closure. A better explanation can be seen here.

1 Like

Oooh, I see. Thank you! :slight_smile: