Configuration.getFiles() on copied configuration return only non-inherited dependencies


I am trying to create a copy of configuration that extends another copied configuration, and I have noticed that getFiles() returns only non-inherited artifacts:

def conf = configurations.runtime.copy()
conf.extendsFrom configurations.compile.copy()

// conf.files returns only artifacts defined in runtime configuration
// conf.allDependencies but shows dependencies defined in compile and runtime configuration

however, configurations.runtime.copyRecursive() works, but this is not an option for me, because in my case compile configuration extends from some other configurations, and I would not like to have artifacts defined there, i.e. I would like to create a configuration that contains artifacts defined in runtime + compile configurations only, respecting all configuration exclude rules.

Am I doing something wrong?



Here is minimal build.gradle that demonstrates the problem:

apply plugin: 'java'

dependencies {

        compile 'org.codehaus.groovy:groovy-all:2.4.6'
        runtime 'io.netty:netty-all:4.0.34.Final'

task runtimeDep << {
        println configurations.runtime.files

task runtimeCopyDep << {
        def conf = configurations.runtime.copy()
        conf.extendsFrom configurations.compile.copy()
        println conf.files

Tested on Gradle 2.11

The method does exactly what the documentation says:
Creates a copy of this configuration that only contains the dependencies directly in this configuration (without contributions from superconfigurations).

You are looking for copyRecursive.

Yes, but after creating the configuration, I have said that it extends from another configuration. Thus, if I understand well, I should get with getFiles() all files, contained in the configuration and the inherited one. Exactly like in runtime configuration - I get all files.