Is it possible to exclude grails plugin from production environment?

爷,独闯天下 提交于 2019-11-29 14:27:34

问题


I would like to use certain plugin in development environment, but would like to exclude this plugin from production and from generated war. What is the easiest way to accomplish this?


回答1:


Yes, using plugin scopes. From http://grails.org/1.1+Release+Notes:

Plugins can now be scoped using either the environment or predefined build scopes:

def environments = ['dev', 'test']
def scopes = [excludes:'war']

The plugins will only load in those environments and will not be packaged into the WAR file. This allows "development-only" plugins to not be packaged for production use.




回答2:


I don't believe that there is a way to achieve this without editing the plugin itself (as Jean pointed out)

If you have control over the plugin then that will work, but if you just wanted to configure this as you were 'using' it, then you will need to copy and run a patched version of the plugin with your modifications. You'd customizing it by utilizing a custom location for that plugin in your grails-app/conf/BuildConfig.groovy file.




回答3:


If you want to exclude the plugin in certain environment, you need to do this:

runtime (':plugin:version') {
    if (Environment.current == Environment.PRODUCTION) {
        export = false
    }
}



回答4:


You can use the excludes property in your config.groovy:

production {
         grails.plugin.excludes='console,classDiagram'
}

But there seems to be some confusion as to if it will exclude it from both 'run-app' and 'war'. I will try to check today and verify



来源:https://stackoverflow.com/questions/1783487/is-it-possible-to-exclude-grails-plugin-from-production-environment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!