Question

I want to exclude cobertura from instrumenting code if test=true.

Right now I have all my required statments at the top:

require 'buildr/java/cobertura'
require 'buildr/scala'

Then each time the build runs I get this:

Instrumenting classes with cobertura data file C:/usr/git_workspaces/reports/cobertura.ser

Which means that my production code has cobertura instrumentation in it.

This is the next section of my build

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...

Is the compile.with the place where compilation actually occurs? So I could make an if test then add cobertura ?

Was it helpful?

Solution

if you do not require "buildr/java/cobertura" then there will be no instrumenting.

We 'solved' like this (at least commandline parameter has to include "cobertura" otherwise the classes are not instrumented)

ARGV.each do |a| 
  if (a.include?("cobertura")) 
    require "buildr/java/cobertura"
    break
  end
end

You could do this

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top