Exclude plugin for specific environment

馋奶兔 提交于 2019-12-05 06:11:08

In your buildConfig.groovy you can define a plugin to not export:

plugins {
  compile(':theplugin:theversion') {
    export = false
  }
}

let me throw an answer in the ring. Similar to what @hitty5 is proposing, but with some changes (and a bug fix).

For us, it is important to exclude some page speed plugins, when working on the DEVELOPMENT environment, as we want to see the resources in full. On the other hand we don't want to copy the plugins that should be on every machine between blocks (like you would have to in @hitty5 's solution).

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"

}

Hope this helps.

All the best, fluxon

first i recommend to use the build config file (BuildConfig.groovy) to resolve your plugin dependencies. inside this file you can define env specific blocks like:

if (environment == Environment.PRODUCTION){
    plugins {            
            compile ":<plugin>:<version>"
        }
    }
else {
        plugins {            
            compile ":<plugin>:<version>"
        }
}

In your BuildConfig.groovy you can define a plugin to not export in a specific environment:

    plugins {
      compile(':theplugin:theversion') {
         if (Environment.getCurrent() == Environment.PRODUCTION) {
            export = false
         }
      }
    }

Remember to add

import grails.util.Environment

at the beginning of BuildConfig.groovy

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