How to replace the usage of deprecated `ConfigureUtil.configureSelf()`

Hello :wave:,

I’m trying to remove dependencies on ConfigureUtil.configureSelf(). The latest Javadoc says I just need a “method with an Action as a single argument” but it seems not working to satisfy the configure() method required by the Configurable interface.

My MCVE project is here, could you share idea to tackle this problem? Thanks in advance!

note: I posted this question at the community slack, but got not help. I think I need to persist this question for future use to get official help from Gradle, so copied and pasted it at here.

My class needs to implement the Configurable interface because it implements the Report interface. The Project#configure() method does not work, it triggers a StackOverflowError because the Project#configure() method invokes this configure method recursively.

Thomas Broyer shared one solution which is used by ClosureBackedAction, and we assume that it is not the best way to go:

closure = (Closure) closure.clone();
closure.setResolveStrategy(Closure.DELEGATE_FIRST);
closure.setDelegate(this);
if (closure.getMaximumNumberOfParameters() == 0) {
    return closure.call();
} else {
    return closure.call(this);
}