Ok, I think I managed pretty much what I intended:

configurations{
instrumentation
}

dependencies {
instrumentation files("${project.buildDir}/cobertura-instrumentation")
 ....
}

sourceSets {

    test {

       runtimeClasspath = configurations.instrumentation + runtimeClasspath
    ...
..
}


I have iterated over the runtimeclasses, and checked that my instrumented
class path is indeed up top, using the script code:

 sourceSets.test.runtimeClasspath.getFiles().each { file ->
println "file: \"" + file + "\""
 }



However, it still doesn't seem to get cobertura to run the instrumented
classes!

I get my instrumented classes written seemingly ok, but nothing is run
(i.e., everything is red, and the lines are all run zero times).

I know the junit tests ARE run, because they all pass, and I get details
from the junit reports.


Any idea what is missing?

Does the junit tests not run from the "testRuntime"  class path?

Thanks!

sean












On 20 July 2011 15:09, Sean Van Buggenum <[email protected]> wrote:

> Hi all,
>
> I'm setting up cobertura instrumentation (code coverage) on my gradle java
> build.
>
> I could do it like suggested by some (copy instrumented classes in place
> before test, move them out after test)
> but that seems a bit ugly.
>
> What would be easy, is if I could simply place these instrumented class
> files ahead of the originals in the classpath;
>
> eg.
>
> dependencies {
> testRuntime files("${project.buildDir}/cobertura-instrumentation")
> .. the rest
> }
>
> However, this doesn't do it. They of course always end up just after the
> originals (which are being built, and don't need explicit placement on the
> dependencies classpath).
>
> According to the gradle documentation, the SourceSetContainer sourceSets is
> read-only
>
>
> http://www.gradle.org/current/docs/dsl/org.gradle.api.Project.html#org.gradle.api.plugins.JavaPluginConvention:sourceSets
>
> This means I can't modify this to slip my instrumented classes in first.
>
> Is there any other way around this ?
>
> Regards,
>
> Sean
>
>
>
>
>
>

Reply via email to