gradle / gradle-native

The home of Gradle's support for natively compiled languages
https://blog.gradle.org/introducing-the-new-cpp-plugins
Apache License 2.0
91 stars 8 forks source link

Demonstrate how to consume static linkage variant of a dual-linkage library #1017

Open lacasseio opened 5 years ago

lacasseio commented 4 years ago

🎉 🎉 🎉 Thanks @ljacomet for helping nailing the right semantic for solving this use case.

Screen Shot 2019-11-20 at 9 21 10 PM

The code should look like this:

library {
    dependencies {
        api(project(':list')) {
            attributes { attribute(Attribute.of("org.gradle.native.linkage", Linkage), Linkage.STATIC) }
        }
    }
}

But because of issue https://github.com/gradle/gradle-native/issues/1053, it needs to look like this:

dependencies {
    api(project(':list')) {
        attributes { attribute(Attribute.of("org.gradle.native.linkage", Linkage), Linkage.STATIC) }
    }
}

Unfortunately, when going through the Project#getDependencies() container, it will make it a bit more complicated when dealing with variants as you will have to know the variant name for the dependency to configure.