如何通过Kotlin/Java编写的Gradle插件设置Gradle插件版本?
因此,我正在使用Kotlin和此类插件(我的插件)编写插件,我安装了其他插件。
从项目对象我可以访问插件字段及其方法。但是,没有任何方法可以让我选择要安装插件的版本。
基本上,我想执行相当于的插件
plugins{
id "org.jetbrains.kotlin.jvm" version "1.6.21"
}
,但在我的插件中,唯一可用的对象(project.plugins
)是类型 pluginContainer
,基本上只有方法apply(string)和方法
应用(类<?>)
。如何使用此接口指定插件的版本?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我将调用您要开发“您的插件”的插件和要应用于“ Sub插件”的插件。
要指定子插件的版本,在插件的build.gradle中,您指定sub插件的gav(group:trifact:version),当您将sub插件应用于sub插件时,将使用该版本您的插件。
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.