Lack of parity with Gradle 3.0 deprecation of changing configurations included in resolution

We have plugins applying resolutionStrategy configurations in beforeResolve to ensure that dependency locking or resolution rules are applied only before the configuration is resolved. However, we see the following warnings:

Changed dependencies of configuration ‘:compileOnly’ after it has been included in dependency resolution. This behaviour has been deprecated and is scheduled to be removed in Gradle 3.0. Use ‘defaultDependencies’ instead of ‘beforeResolve’ to specify default dependencies for a configuration.

It’s because beforeResolve only triggers before a configuration is resolved, however it’s considered to have been included in dependency resolution when any of the configurations that it extends from have been resolved.

Unfortunately, the suggested alternative defaultDependencies isn’t a help as it stands - it appears to fire early enough that we could affect the configuration, in fact it fires after beforeResolve so gives us the late-as-possible hook we need, but unfortunately it only fires when the configuration is empty.

Given this looming deprecation, how can we reliably configure configurations in this way, when they extend from others? A handler just like defaultDependencies that always triggers on the same event would be ideal.

Some background:

Failing test and failing experiment with defaultDependencies:

https://github.com/nebula-plugins/gradle-resolution-rules-plugin/compare/default-dependencies?expand=1

In fact, I think only excludes are causing this. If so, we can safely apply those when the plugin applies, rather than in beforeResolve. Need to spend more time on this…

False alarm - Turns out this is indeed only excludes affected, so nothing needed here.