This message was deleted.
# dependency-management
s
This message was deleted.
a
are you using the feature variant config for your Java variants? If so, I'd look at the way that Gradle suggest implementing a Gradle plugin that's compatible with multiple Gradle versions https://docs.gradle.org/current/userguide/implementing_gradle_plugins.html#plugin-with-variants. Specifically how they find the Configurations for each feature variant by name, and then add a specific attribute. You'd want to add the JVM version attribute instead of the Gradle version attribute.
v
That's an interesting guide as well; however it looks like it's missing the publishing information as well? Unless that's set up automatically with the java.registerFeature stuff?
I also found this; looks like that's closer to what I want to do https://docs.gradle.org/6.9.1/userguide/cross_project_publications.html#sec:variant-aware-sharing
v
You don't need to set any attributes manually for the multiple java versions case. If you declared multiple feature variants, the toolchain of the
compile...Java
task for each feature variant is queried to determine matching values for the attribute.
An alternative if you do not need different dependencies would be to build a multi-release jar
v
So, for compiling against different Java versions, I'll have to add a feature variant, just like adding any other feature variants would work? Except that the capability is set to the GAV of the project itself?
Multi-release jar won't work here, because there are different dependencies
v
Yes, exactly. The easiest should be that you add a second feature variant and set the capability of the additional variant to be equal to the main capability and thus coordinates.
You can also easily check the result using the
outgoingVariants
task which shows the outgoing variants including attributes