排除特定环境的插件

Tho*_*ley 6 grails grails-plugin

我正在使用grails 2.1.

我需要在构建生产时排除插件.

这篇文章提到了向插件添加范围.我相信这需要编辑单独的插件描述符?

我想定义要在一个位置排除的插件.

我尝试将以下内容添加到config.groovy:

environments {
    production {
    plugin.excludes='grails-melody'
    }
}
Run Code Online (Sandbox Code Playgroud)

当我查看战争时,它仍然包含WEB-INF/plugins下的旋律文件夹.

我应该补充说,大多数应用程序插件都在application.properties中指定,如下所示:

plugins.build-test-data=2.0.3
plugins.fixtures=1.1
plugins.geoip=0.2
plugins.grails-melody=1.12
etc...
Run Code Online (Sandbox Code Playgroud)

如何排除生产版本的特定插件?

谢谢

Sér*_*els 8

在buildConfig.groovy中,您可以定义一个不导出的插件:

plugins {
  compile(':theplugin:theversion') {
    export = false
  }
}
Run Code Online (Sandbox Code Playgroud)


flu*_*xon 7

让我在戒指中回答.与@ hitty5提议的类似,但有一些变化(以及错误修复).

对于我们来说,在开发环境中工作时排除一些页面速度插件非常重要,因为我们希望完整地查看资源.另一方面,我们不想复制块之间应该在每台机器上的插件(就像在@ hitty5的解决方案中一样).

plugins {
    runtime ":hibernate:$grailsVersion"
    // ... some more plugins that I want in every environment

    if (Environment.getCurrent() in [Environment.PRODUCTION, Environment.TEST]) {
        // plugins, that I only want on the test and production servers
        println("BuildConfig: including page speed optimization plugins.")
        runtime ":zipped-resources:1.0"
        compile ":cache-headers:1.1.5"
        runtime ":cached-resources:1.0"
        runtime ":yui-minify-resources:0.1.5"
    }

    // ... and more plugins, if you like
    build ":tomcat:$grailsVersion"

}
Run Code Online (Sandbox Code Playgroud)

希望这可以帮助.

一切顺利,fluxon