Working with evaluation order is a challenge when writing plugins, and this requires knowledge and experience.
Please note that in the script assembly the plugin is applied (and therefore executed!) Before the version is installed. This is the norm, and the plugin must handle this. Roughly speaking, whenever a plugin accesses a mutable property of the Gradle object model, it must defer this access until the end of the configuration phase. (Until then, the value of the property may still change.)
Some of the Gradle APIs (lazy collections, methods that receive callbacks, etc.) provide special support to solve this problem. In addition, you can wrap the affected code in project.gradle.projectsEvaluated { ... } or use the more sophisticated technique of mapping symbols.
The Gradle User Guide and http://forums.gradle.org provide additional information on these topics.
Peter Niederwieser
source share