Hi all,
I need some guidance on how to make my plugin configuration-cache friendly.
For work, I created a Gradle plugin that automatically writes a Git hook when it is applied (for those who are familiar with the NPM ecosystem, think like husky). The way I do this is by looking up the hook which should be configured from an extension and comparing what the current hook is (if one exists) with what should be written. To ensure the extension value is available, I run all of this in an afterEvaluate block.
Right now, all of this happens during configuration time (and seems to be fast enough). However, the code uses Freemarker templates, and when creating one of its Configuration objects, a method is called that reads the “file.encoding” property. I don’t have an opportunity to tell it to use a value I can extract from a provider returned by the systemProperty() method. So my direct question is regarding how to deal with this scenario.
All of this has also made me reconsider whether this logic should be part of the configuration of the build. Perhaps this should be a task, but is it then possible to always run this task before user selected tasks?
Thank you to anyone who takes the time to read this, and even more if you have suggestions.