简体   繁体   中英

How to set gradle plugin version from gradle plugin written in Kotlin/Java?

So I'm writing a plugin using Kotlin and in such plugin (my plugin), I install other plugins.

From the project object I can access the plugins field, and its methods. Yet there's no method that allows me to pick the version I'm gonna install of the plugin.

Basically I want to do the equivalent of

plugins{
  id "org.jetbrains.kotlin.jvm" version "1.6.21"
}

But in my plugin the only available object ( project.plugins ) is of type PluginContainer , which basically only has the method apply(String) and the method apply(Class<?>) . How do I specify the version of the plugin using this interface?

I'll call the plugin you're developing "your plugin" and the plugin you want to apply as the "sub plugin".

To specify the version of the sub plugin, in the build.gradle of your plugin, you specify the GAV (group:artifact:version) of the sub plugin, and it's that version that'll be used when you apply the sub plugin in your plugin.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM