是否可以从BuildConfig.groovy文件中知道正在执行哪个命令,以便根据命令更改构建配置?例如,如果“schema-export”不包含“Foo”库,等等?
我正在使用Eclipse,并且正在从Eclipse运行rails cmd。
编辑:尝试了Shashank解决方案后,我添加了有关我正在使用Eclipse的事实的详细信息。
通过打印'sun.java.command'属性,我认为我的Eclipse安装(Indigo Service Release 2 + Grails IDE 3.5插件)正在重写启动到的命令。
org.codehaus.groovy.grails.cli.support.GrailsStarter --main org.grails.ide.eclipse.longrunning.process.GrailsProcess --conf Y:\grails-2.4.4\/conf/groovy-starter.conf --classpath /C:/Program Files/eclipse/configuration/org.eclipse.osgi/bundles/1764/1/.cp/;/C:/Program Files/eclipse/configuration/org.eclipse.osgi/bundles/1766/1/.cp/ --is14
最佳答案
我看着它,是的,这是绝对可能的。
在BuildConfig中的任何地方,您可以编写如下内容:
String command = System.getProperty("sun.java.command")
if (command.contains("run-app")) {
compile (":hibernate:3.6.10.18") // example to install hibernate while running the app
} else if (command.contains("test-app")) {
compile (":hibernate:3.6.10.14") // some other version for test cases
}
compile (":some-plugin:2.3") {
if (command.contains("export-schema")) {
excludes "foo"
}
}
org.codehaus.groovy.grails.cli.support.GrailsStarter --main org.codehaus.groovy.grails.cli.GrailsScriptRunner --conf /home/user/.gvm/grails/current/conf/groovy-starter.conf --classpath --offline run-app
https://stackoverflow.com/questions/29541539/
相关文章:
php - PHP Net_SSH2-exec()如何获取命令返回码
mongodb - 在grails和MongoDB插件的条件查询中使用allowDiskUse?
ssh - 将现有的 ssh_authorized_keys 导入 puppet 资源
grails - 使用插件时如何在Grails中添加Quartz监听器
security - 在 Groovy 动态 SQL 中检测 SQL 注入(inject)
grails - 路由到webapp文件夹时,将默认渲染文件设置为grails 3中的index.h
amazon-web-services - AWS EC2 - 为什么连接时我的 SSH 公钥不存在