问题
I'm using grails 2.1.
I need to exclude a plugin when building for production.
This post mentions adding scopes to the plugins. I believe this requires editing indivudual plugin descriptors?
I would like to define plugins to exclude in one location.
I have tried adding the following to config.groovy:
environments {
production {
plugin.excludes='grails-melody'
}
}
When I check the war it still contains the melody folder under WEB-INF/plugins.
I should add that most of the application plugins are specified in application.properties as follows:
plugins.build-test-data=2.0.3
plugins.fixtures=1.1
plugins.geoip=0.2
plugins.grails-melody=1.12
etc...
How can I exclude specific plugins for production builds?
Thanks
回答1:
In your buildConfig.groovy you can define a plugin to not export:
plugins {
compile(':theplugin:theversion') {
export = false
}
}
回答2:
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
回答3:
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>"
}
}
回答4:
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
来源:https://stackoverflow.com/questions/14501444/exclude-plugin-for-specific-environment