Resolving runtime + compile classpath config

In my plugin I need to be resolving project’s Java compile plus runtime dependencies. I used to be resolving JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME and then JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME.
Now I noticed this warning

The compileOnly configuration has been deprecated for resolution. This will fail with an error in Gradle 7.0. Please resolve the compileClasspath configuration instead. Consult the upgrading guide for further information:

So now I am switching from JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME to JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME. That works of course but I have to be filtering out the duplicate deps that constitute probably 99% or even 100% most of the time.
Perhaps, there is a more efficient and supported way of achieving the same result? Thanks.

It sounds like you should create your own configuration that extends from the configurations that you care about. Resolving compileOnly directly is deprecated (as is anything green in the diagram below), but the alternative provided, compileClasspath is just another configuration that extends from it. You have the option if you want to extend your original compileOnly or compileClasspath along with runtimeClasspath, which when resolved will give you exactly the union of the two, without duplicates.

from Java Plugin - Dependency Configurations

extendsFrom(...) was what I needed indeed. Thanks a lot @jjustinic !