Copy from transitive native dependencies

We are progressing adoption of Gradle in our native projects. Gradle native support in version 6.0 seems very, very promising, thank you for your hard work!

Currently, we are investigating how to package modules built by us with their dependencies. Our final target is to build MSI packages with the Wix Toolset.

Composite builds work very well for us in JVM projects. We tried the same basic technique we use in those projects. In the following, “prodist:apr-util” and its dependencies are all provided by included builds.

configurations {
    install
}

dependencies {
    install group: 'prodist', name: 'apr-util'
}

tasks.register('install', Copy) {
    from configurations.install
    into layout.buildDir
}

Calling gradle install generates the following report:

> Could not resolve all task dependencies for configuration ':install'.
   > Could not resolve prodist:apr-util.
     Required by:
         project :
      > Cannot choose between the following variants of project :apr-util:
          - cppApiElements
          - debugLinkElements
          - debugRuntimeElements
          - releaseLinkElements
          - releaseRuntimeElements
        All of them match the consumer attributes:
          - Variant 'cppApiElements' capability prodist:apr-util:7.0.0:
              - Unmatched attributes:
                  - Found artifactType 'directory' but wasn't required.
                  - Found org.gradle.usage 'cplusplus-api' but wasn't required.
          - Variant 'debugLinkElements' capability prodist:apr-util:7.0.0:
              - Unmatched attributes:
                  - Found org.gradle.native.architecture 'x86-64' but wasn't required.
                  - Found org.gradle.native.debuggable 'true' but wasn't required.
                  - Found org.gradle.native.linkage 'SHARED' but wasn't required.
                  - Found org.gradle.native.operatingSystem 'windows' but wasn't required.
                  - Found org.gradle.native.optimized 'false' but wasn't required.
                  - Found org.gradle.usage 'native-link' but wasn't required.
          - Variant 'debugRuntimeElements' capability prodist:apr-util:7.0.0:
              - Unmatched attributes:
                  - Found org.gradle.native.architecture 'x86-64' but wasn't required.
                  - Found org.gradle.native.debuggable 'true' but wasn't required.
                  - Found org.gradle.native.linkage 'SHARED' but wasn't required.
                  - Found org.gradle.native.operatingSystem 'windows' but wasn't required.
                  - Found org.gradle.native.optimized 'false' but wasn't required.
                  - Found org.gradle.usage 'native-runtime' but wasn't required.
          - Variant 'releaseLinkElements' capability prodist:apr-util:7.0.0:
              - Unmatched attributes:
                  - Found org.gradle.native.architecture 'x86-64' but wasn't required.
                  - Found org.gradle.native.debuggable 'true' but wasn't required.
                  - Found org.gradle.native.linkage 'SHARED' but wasn't required.
                  - Found org.gradle.native.operatingSystem 'windows' but wasn't required.
                  - Found org.gradle.native.optimized 'true' but wasn't required.
                  - Found org.gradle.usage 'native-link' but wasn't required.
          - Variant 'releaseRuntimeElements' capability prodist:apr-util:7.0.0:
              - Unmatched attributes:
                  - Found org.gradle.native.architecture 'x86-64' but wasn't required.
                  - Found org.gradle.native.debuggable 'true' but wasn't required.
                  - Found org.gradle.native.linkage 'SHARED' but wasn't required.
                  - Found org.gradle.native.operatingSystem 'windows' but wasn't required.
                  - Found org.gradle.native.optimized 'true' but wasn't required.
                  - Found org.gradle.usage 'native-runtime' but wasn't required.

With tried defining a “configuration”, like this:

configurations {
    install
}

dependencies {
    install group: 'prodist', name: 'apr-util', configuration: 'debugRuntimeElements'
}

tasks.register('install', Copy) {
    from configurations.install
    into layout.buildDir
}

Defining “configuration” helps Gradle resolve “prodist:apr-util” but doesn’t help resolving its dependencies:

Could not determine the dependencies of task ':install'.
> Could not resolve all task dependencies for configuration ':install'.
   > Could not resolve prodist:apr:7.0.0.
     Required by:
         project : > project :apr-util
      > Cannot choose between the following variants of project :apr:
          - cppApiElements
          - debugLinkElements
          - debugRuntimeElements
          - releaseLinkElements
          - releaseRuntimeElements
        All of them match the consumer attributes:
          - Variant 'cppApiElements' capability prodist:apr:7.0.0:
              - Unmatched attributes:
                  - Found artifactType 'directory' but wasn't required.
                  - Found org.gradle.usage 'cplusplus-api' but wasn't required.
          - Variant 'debugLinkElements' capability prodist:apr:7.0.0:
              - Unmatched attributes:
                  - Found org.gradle.native.architecture 'x86-64' but wasn't required.
                  - Found org.gradle.native.debuggable 'true' but wasn't required.
                  - Found org.gradle.native.linkage 'SHARED' but wasn't required.
                  - Found org.gradle.native.operatingSystem 'windows' but wasn't required.
                  - Found org.gradle.native.optimized 'false' but wasn't required.
                  - Found org.gradle.usage 'native-link' but wasn't required.
          - Variant 'debugRuntimeElements' capability prodist:apr:7.0.0:
              - Unmatched attributes:
                  - Found org.gradle.native.architecture 'x86-64' but wasn't required.
                  - Found org.gradle.native.debuggable 'true' but wasn't required.
                  - Found org.gradle.native.linkage 'SHARED' but wasn't required.
                  - Found org.gradle.native.operatingSystem 'windows' but wasn't required.
                  - Found org.gradle.native.optimized 'false' but wasn't required.
                  - Found org.gradle.usage 'native-runtime' but wasn't required.
          - Variant 'releaseLinkElements' capability prodist:apr:7.0.0:
              - Unmatched attributes:
                  - Found org.gradle.native.architecture 'x86-64' but wasn't required.
                  - Found org.gradle.native.debuggable 'true' but wasn't required.
                  - Found org.gradle.native.linkage 'SHARED' but wasn't required.
                  - Found org.gradle.native.operatingSystem 'windows' but wasn't required.
                  - Found org.gradle.native.optimized 'true' but wasn't required.
                  - Found org.gradle.usage 'native-link' but wasn't required.
          - Variant 'releaseRuntimeElements' capability prodist:apr:7.0.0:
              - Unmatched attributes:
                  - Found org.gradle.native.architecture 'x86-64' but wasn't required.
                  - Found org.gradle.native.debuggable 'true' but wasn't required.
                  - Found org.gradle.native.linkage 'SHARED' but wasn't required.
                  - Found org.gradle.native.operatingSystem 'windows' but wasn't required.
                  - Found org.gradle.native.optimized 'true' but wasn't required.
                  - Found org.gradle.usage 'native-runtime' but wasn't required.
   > Could not resolve prodist:apr-iconv:7.0.0.
     Required by:
         project : > project :apr-util
      > Cannot choose between the following variants of project :apr-iconv:
          - cppApiElements
          - debugLinkElements
          - debugRuntimeElements
          - releaseLinkElements
          - releaseRuntimeElements
        All of them match the consumer attributes:
          - Variant 'cppApiElements' capability prodist:apr-iconv:7.0.0:
              - Unmatched attributes:
                  - Found artifactType 'directory' but wasn't required.
                  - Found org.gradle.usage 'cplusplus-api' but wasn't required.
          - Variant 'debugLinkElements' capability prodist:apr-iconv:7.0.0:
              - Unmatched attributes:
                  - Found org.gradle.native.architecture 'x86-64' but wasn't required.
                  - Found org.gradle.native.debuggable 'true' but wasn't required.
                  - Found org.gradle.native.linkage 'SHARED' but wasn't required.
                  - Found org.gradle.native.operatingSystem 'windows' but wasn't required.
                  - Found org.gradle.native.optimized 'false' but wasn't required.
                  - Found org.gradle.usage 'native-link' but wasn't required.
          - Variant 'debugRuntimeElements' capability prodist:apr-iconv:7.0.0:
              - Unmatched attributes:
                  - Found org.gradle.native.architecture 'x86-64' but wasn't required.
                  - Found org.gradle.native.debuggable 'true' but wasn't required.
                  - Found org.gradle.native.linkage 'SHARED' but wasn't required.
                  - Found org.gradle.native.operatingSystem 'windows' but wasn't required.
                  - Found org.gradle.native.optimized 'false' but wasn't required.
                  - Found org.gradle.usage 'native-runtime' but wasn't required.
          - Variant 'releaseLinkElements' capability prodist:apr-iconv:7.0.0:
              - Unmatched attributes:
                  - Found org.gradle.native.architecture 'x86-64' but wasn't required.
                  - Found org.gradle.native.debuggable 'true' but wasn't required.
                  - Found org.gradle.native.linkage 'SHARED' but wasn't required.
                  - Found org.gradle.native.operatingSystem 'windows' but wasn't required.
                  - Found org.gradle.native.optimized 'true' but wasn't required.
                  - Found org.gradle.usage 'native-link' but wasn't required.
          - Variant 'releaseRuntimeElements' capability prodist:apr-iconv:7.0.0:
              - Unmatched attributes:
                  - Found org.gradle.native.architecture 'x86-64' but wasn't required.
                  - Found org.gradle.native.debuggable 'true' but wasn't required.
                  - Found org.gradle.native.linkage 'SHARED' but wasn't required.
                  - Found org.gradle.native.operatingSystem 'windows' but wasn't required.
                  - Found org.gradle.native.optimized 'true' but wasn't required.
                  - Found org.gradle.usage 'native-runtime' but wasn't required.
   > Could not resolve prodist:expat:2.2.5.
     Required by:
         project : > project :apr-util
      > Cannot choose between the following variants of project :expat:
          - cppApiElements
          - debugLinkElements
          - debugRuntimeElements
          - releaseLinkElements
          - releaseRuntimeElements
        All of them match the consumer attributes:
          - Variant 'cppApiElements' capability prodist:expat:2.2.5:
              - Unmatched attributes:
                  - Found artifactType 'directory' but wasn't required.
                  - Found org.gradle.usage 'cplusplus-api' but wasn't required.
          - Variant 'debugLinkElements' capability prodist:expat:2.2.5:
              - Unmatched attributes:
                  - Found org.gradle.native.architecture 'x86-64' but wasn't required.
                  - Found org.gradle.native.debuggable 'true' but wasn't required.
                  - Found org.gradle.native.linkage 'SHARED' but wasn't required.
                  - Found org.gradle.native.operatingSystem 'windows' but wasn't required.
                  - Found org.gradle.native.optimized 'false' but wasn't required.
                  - Found org.gradle.usage 'native-link' but wasn't required.
          - Variant 'debugRuntimeElements' capability prodist:expat:2.2.5:
              - Unmatched attributes:
                  - Found org.gradle.native.architecture 'x86-64' but wasn't required.
                  - Found org.gradle.native.debuggable 'true' but wasn't required.
                  - Found org.gradle.native.linkage 'SHARED' but wasn't required.
                  - Found org.gradle.native.operatingSystem 'windows' but wasn't required.
                  - Found org.gradle.native.optimized 'false' but wasn't required.
                  - Found org.gradle.usage 'native-runtime' but wasn't required.
          - Variant 'releaseLinkElements' capability prodist:expat:2.2.5:
              - Unmatched attributes:
                  - Found org.gradle.native.architecture 'x86-64' but wasn't required.
                  - Found org.gradle.native.debuggable 'true' but wasn't required.
                  - Found org.gradle.native.linkage 'SHARED' but wasn't required.
                  - Found org.gradle.native.operatingSystem 'windows' but wasn't required.
                  - Found org.gradle.native.optimized 'true' but wasn't required.
                  - Found org.gradle.usage 'native-link' but wasn't required.
          - Variant 'releaseRuntimeElements' capability prodist:expat:2.2.5:
              - Unmatched attributes:
                  - Found org.gradle.native.architecture 'x86-64' but wasn't required.
                  - Found org.gradle.native.debuggable 'true' but wasn't required.
                  - Found org.gradle.native.linkage 'SHARED' but wasn't required.
                  - Found org.gradle.native.operatingSystem 'windows' but wasn't required.
                  - Found org.gradle.native.optimized 'true' but wasn't required.
                  - Found org.gradle.usage 'native-runtime' but wasn't required.

We have studied the dependency contraints feature but found nothing to help us solve this issue. Have we missed something?