How to Apply Conditional Dependencies in Gradle for Multi-Version Plugin Support?

Hello

I am currently developing a plugin that targets multiple versions of IntelliJ IDEA (2021.3 through 2024.1) & I am running into challenges managing conditional dependencies in the build.gradle.kts file. :innocent:

Some dependencies are only available or compatible with specific IDE versions & applying them globally leads to runtime errors or build failures on older versions. Has anyone successfully implemented conditional logic in Gradle to handle this kind of multi-target support? :thinking:

I have explored using simple if conditions in the dependencies block based on intellij.version; but this approach seems brittle and doesn’t scale well when targeting several versions with slightly differing APIs. :thinking:

I am curious if there’s a cleaner or more idiomatic Gradle/Kotlin DSL approach perhaps using custom Gradle properties, version mapping / helper functions within the script. :slightly_smiling_face:Bonus if it works cleanly with the IntelliJ Gradle Plugin and supports tasks like runIde per version. Checked IntelliJ Platform Gradle Plugin (2.x) | IntelliJ Platform Plugin SDK documentation guide for reference.

If anyone has a sample script, best practices / a public repo that demonstrates managing plugin dependencies based on IntelliJ platform version, I would love to see it. :slightly_smiling_face: How tools like QlikView handle compatibility across data sources; understanding what is QlikView helps draw parallels in managing version-specific dependencies in Gradle. :upside_down_face:

Also; is there a preferred strategy for setting up automated CI to test builds against multiple IntelliJ versions using this plugin system? :thinking:

Thanks in advance! :slightly_smiling_face: