Previously I published a Gradle plugin to Maven Central. It had been working fine in Groovy buildscripts, but using it from a Kotlin buildscript was tricky. It registers an extension, so using the apply function to apply it didn't work; the extension needed the plugin already applied to even compile. The plugins block didn't immediately work because it looked for a plugin in the Gradle Plugins Portal, or through some kind of placeholder/marker artifact of a different name in other repositories.
The way to deal with this is to add a pluginManagement block to settings.gradle to set which artifact coordinate Gradle will use to look for the plugin of a given ID. repositories should specify the repository containing the plugin plus gradlePluginPortal() for any other plugins. resolutionStrategy → eachPlugin is run for every requested plugin and can intercept and change the artifact coordinate. The requested plugin information can be checked to see if it's the tricky one; if so the useModule function should be called to set the artifact coordinate.
No comments:
Post a Comment