I have a plugin which uses kotlin 1.9.x by default and hence supports only gradle 8.x or above. I want to add optional support for gradle 7.x via feature variants via lowering the kotlin version for the gradle7
variant, but when the consumer (with gradle 7.x) is trying to import the plugin, it gets a “No matching variant found”
I’m not entirely sure what I’m missing to get this working, but here’s a diff of what I’ve added to enable supporting gradle7 - Comparing master...gradle7 · serpro69/semver.kt · GitHub
The error I’m getting is this:
Could not resolve all artifacts for configuration 'classpath'.
> Could not resolve io.github.serpro69:semantic-versioning:0.0.0-dev.
Required by:
unspecified:unspecified:unspecified > io.github.serpro69.semantic-versioning:io.github.serpro69.semantic-versioning.gradle.plugin:0.0.0-dev
> No matching variant of io.github.serpro69:semantic-versioning:0.0.0-dev was found. The consumer was configured to find a runtime of a library compatible with Java 17, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '7.2' but:
- Variant 'apiElements' capability io.github.serpro69:semantic-versioning:0.0.0-dev declares a library compatible with Java 17, packaged as a jar, and its dependencies declared externally:
- Incompatible because this component declares an API of a component, as well as attribute 'org.gradle.plugin.api-version' with value '8.0' and the consumer needed a runtime of a component, as well as attribute 'org.gradle.plugin.api-version' with value '7.2'
- Variant 'gradle7ApiElements' capability io.github.serpro69:semantic-versioning-gradle7:0.0.0-dev declares a library compatible with Java 17, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '7.2':
- Incompatible because this component declares an API of a component and the consumer needed a runtime of a component
- Variant 'gradle7RuntimeElements' capability io.github.serpro69:semantic-versioning-gradle7:0.0.0-dev declares a runtime of a library compatible with Java 17, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '7.2'
- Variant 'javadocElements' capability io.github.serpro69:semantic-versioning:0.0.0-dev declares a runtime of a component, and its dependencies declared externally:
- Incompatible because this component declares documentation, as well as attribute 'org.gradle.plugin.api-version' with value '8.0' and the consumer needed a library, as well as attribute 'org.gradle.plugin.api-version' with value '7.2'
- Other compatible attributes:
- Doesn't say anything about its target Java version (required compatibility with Java 17)
- Doesn't say anything about its elements (required them packaged as a jar)
- Variant 'runtimeElements' capability io.github.serpro69:semantic-versioning:0.0.0-dev declares a runtime of a library compatible with Java 17, packaged as a jar, and its dependencies declared externally:
- Incompatible because this component declares a component, as well as attribute 'org.gradle.plugin.api-version' with value '8.0' and the consumer needed a component, as well as attribute 'org.gradle.plugin.api-version' with value '7.2'
- Variant 'sourcesElements' capability io.github.serpro69:semantic-versioning:0.0.0-dev declares a runtime of a component, and its dependencies declared externally:
- Incompatible because this component declares documentation, as well as attribute 'org.gradle.plugin.api-version' with value '8.0' and the consumer needed a library, as well as attribute 'org.gradle.plugin.api-version' with value '7.2'
- Other compatible attributes:
- Doesn't say anything about its target Java version (required compatibility with Java 17)
- Doesn't say anything about its elements (required them packaged as a jar)
Particularly, I think I need to fix this one:
- Variant 'gradle7ApiElements' capability io.github.serpro69:semantic-versioning-gradle7:0.0.0-dev declares a library compatible with Java 17, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '7.2':
- Incompatible because this component declares an API of a component and the consumer needed a runtime of a component
since the gradle7RuntimeElements
seems to be ok, and I don’t think I need to bother about the rest?
I’m not sure why this reason is shown, because I’ve pretty much declared same things for both default variant and the gradle7
one, with only difference being kotlin dependencies version. And the default variant works just fine with gradle 8.+
Documentation on feature variants is quite scarce so I’m hoping someone who knows well enough how it works could help me fix this.
Thanks in advance.