Gradle plugins make use of the gradle API via a dependency declaration on a special “gradleApi” method. This restricts the version of the API to be the same as the version of gradle used to compile the plugin.
We have a use case where we need to continue to support older API versions (2.x for now but will be bumped up in the future) while using newer plugins that require newer versions of gradle (such as spring boot and xtext-gradle-plugin). Thus far we have been doing this by building with 2.13 and ensuring forwards compatibility through integration testing and keeping our plugins pinned to older versions. We want to upgrade our plugins and so need to bump up the version of Gradle we build with plugins with.
Is there a way to execute Gradle on one version but compile a plugin against a different API version? For example, could we create a BOM dependency that pulls in api dependencies in lieu of using gradleApi()? Does such a feature or module already exist?
This is the exact use case the plugins at GitHub - gradle-plugins/toolbox: Painless and fast Gradle plugin development are solving. You don’t need to use the plugins to access the various Gradle APIs. You can resolve the dependencies at dev.gradleplugins:gradle-api:<version>. However, keep in mind that the core java-gradle-plugin plugin adds a self resolved dependencies which would need to be removed. The toolbox plugins take cares of that and much more.