I have a library that uses JAXB, which has been removed from Java 11. My library must be compatible with both Java 8 and Java 11. Building & testing the library is easy enough, as I add the following dependency if a Java 11 runtime is detected during the build:
implementation "com.sun.xml.bind:jaxb-impl:2.3.3"
However, my goal is to publish metadata with two variants, one with attribute org.gradle.jvm.version set to 8 without the JAXB dependency, and one with attribute org.gradle.jvm.version set to 11 and the JAXB dependency. I’d also like for this to be transparent to the consumer, i.e. that its dependency declaration remains
implementation "foo:bar:1.0.0"
Is this possible with the current version of Gradle? By declaring a variant of the default capability?