如果test = true,我想将cobertura排除在检测代码之外。
现在我在顶部提供了所有必需的声明:
require 'buildr/java/cobertura'
require 'buildr/scala'
然后每次构建运行时我都会得到:
使用cobertura数据文件检测类 C:/usr/git_workspaces/reports/cobertura.ser
这意味着我的生产代码中包含了cobertura工具。
这是我构建的下一部分
compile.with CORE, SLF4J, LOG4J, WS_CLIENTS, JODA_TIME,
[omitted for brevity]
compile.options.other = %w(-encoding UTF-8)
cobertura.exclude '[omitted for brevity]'
resources.filter.using *RESOURCES_FILTER
test.using :junit
# need this because of forking. It does not appear to use the environmental variables defined above.
test.using :java_args => ["-XX:MaxPermSize=128M"]
test.with JUNIT, SCALATEST, MOCKITO, POWERMOCK, HAMCREST, SPRING.test
# Pakcage is below here but the code has already been instrumented...
compile.with编译实际发生的地方?所以我可以做一个if测试,然后添加cobertura?
答案 0 :(得分:2)
如果你不需要“buildr / java / cobertura”那么就没有工具了。
我们'解决了'这样(至少命令行参数必须包含“cobertura”,否则这些类没有检测)
ARGV.each do |a|
if (a.include?("cobertura"))
require "buildr/java/cobertura"
break
end
end
你可以这样做
require_cb = ture
ARGV.each do |a|
if (a.include?("test=yes"))
require_cb = false
break
end
end
require "buildr/java/cobertura" if require_cb
HTH