JACOCO integration: expose a way to derive class directories in a custom fashion


(Davide Cavestro) #1

I need a way to exclude some contents from the classpath passed to the jacoco ant task. Actually “getClassDirs()” uses an hard-coded closure in order to produce a file collection. Having a way to specify a custom one could be useful in some cases.

Real-world scenario: I have some jars within the resources folder. They are part of a report framework that supports hot deploy. That jars are the standard ones. btw that are placed into a folder hierarchy and this way they can be loaded - at runtime - by ad-hoc classloaders. Since every jar is loaded into an isolated space (i.e. the custom classloader) some jars contains classes with identical FQN but different contents. Now, I don’t want coverage analysis for those jars contents, but I guess jacoco load classes from every jar passed from the classesDir FileCollection. I’d just need a way to exclude those jars from my sourceSets output.

PS: Andrew Oberstar asked me to fill this idea as the evolution issue 10 from of the old/external gradle-jacoco plugin issue tracker. He said he’d work on a more flexible API.


(Andrew Oberstar) #2

Just to clarify, they’ve made some changes to the way ‘getClassDirs’ works since integrating it. I don’t know that it addresses your use case, but it might be worth taking a look at the current implementation.

I didn’t get very far in thinking of a nicer API. Perhaps the devs will have some ideas.