简体   繁体   English

链接Grails插件?

[英]Chaining Grails Plugins?

I am trying to build a Grails plugin that will act as a "master plugin" for a suite of other Grails apps. 我正在尝试构建一个Grails插件,该插件将充当其他Grails应用程序套件的“主插件”。

I am wondering if it is possible to somehow chain plugins together transitively? 我想知道是否有可能以某种方式连锁插件一起及物? Pretend that Plugin A depends on Plugin B , and that Grails App GA1 uses (installs) Plugin A . 假设插件A依赖于插件B ,并且Grails App GA1使用(安装) 插件A。 When the developer does this install of Plugin A (the "master") to Grails App GA1 , they end up installing Plugin A as well as Plugin B , transitively. 当开发人员将此插件A (“主”)安装到Grails App GA1时 ,他们最终将通过传递方式同时安装插件A插件B。

Is this possible? 这可能吗? If so, how? 如果是这样,怎么办? If not, why, and is there a way to hack this or is there a better way to transitively install plugins in general? 如果不是,为什么,并且有办法破解此漏洞,或者有更好的方法通常以可传递方式安装插件?

Pretend that Plugin A depends on Plugin B 假设插件A依赖于插件B

This means that your Plugin A BuildConfig will have: 这意味着您的Plugin A BuildConfig将具有:

plugins {
  compile ':pluginB:...'
}

When you install Plugin A in your application, Grails will automatically download and install plugin B too. 当您在应用程序中安装插件A时,Grails也会自动下载并安装插件B。

This is also true for the dependencies block. 对于依赖项块也是如此。 So yes , you can have a plugin that depends on a list of plugins and the application will install all of them. 所以是的 ,您可以拥有一个依赖于一系列插件的插件,应用程序将安装所有插件。 This is the default behavior of using plugins in Grails. 这是在Grails中使用插件的默认行为。

On the contrary, if you want not to get Plugin C (if there is any which is used by Plugin A), when Plugin A is used in the Grails App then you can selectively block the transitivity of pulling Plugin C into the app. 相反,如果你想不要插件C(如果有任何它使用的插件A),当在Grails的应用程序使用一个插件 ,那么你可以有选择性地阻止拉插件C处于应用的传递。 Inside BuildConfig of Plugin A, you can specify: 在插件A的BuildConfig中,您可以指定:

plugins {
    compile(':pluginC:...') {
        //makes sure Plugin C is not available 
        //when Plugin A is used in the app
        export = false 
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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