I would like to write a plugin that provides an Ant task, but I cannot work out how to do it. I haven’t been able to find any examples where someone has done this. Can anyone suggest a good pattern for achieving this, or point me to a working example?
I can use the task directly in the build script with the usual ant.taskdef/ant.taskname idiom, but this takes quite a lot of boilerplate that I would like to encapsulate in the plugin so that the task can be easily applied and invoked the same way in multiple projects. It sounds to me like it should be doable, but I keep hitting one problem or another and I haven’t managed it yet. I would prefer to write the plugin in Groovy or Java, but I’ll consider any approach.
Thanks for the pointer, it is a great help! I’m new to gradle and I hadn’t spotted the “detachedConfiguration” method in the API, and that was making me go round in circles.
It seems odd to me that it is an instance method of ConfigurationContainer when the instance’s state is not changed by the method call, but I guess that there is a rationale for that.
The ConfigurationContainer is the factory for Configuration instances so seems logical to me. I’m not convinced the instance`s state is not changed, it’s likely it holds a reference to the detached configuration.