I am using the example on http://www.eclemma.org/jacoco/trunk/doc/examples/java/ReportGenerator.java
I would like to exclude some classes from the report generation. I assume it has to be set in the Analyzer but I could find an example.
I am using the example on http://www.eclemma.org/jacoco/trunk/doc/examples/java/ReportGenerator.java
I would like to exclude some classes from the report generation. I assume it has to be set in the Analyzer but I could find an example.
Sounds like you may be wanting the Excludes: in Code Coverage Preferences ?
I'd say in analyzeStructure()
you should not call analyzer.analyzeAll(classesDirectory);
, but iterate over the file tree in classesDirectory
yourself, excluding the classes you don't want to have analyzed and then give the individual files to the analzyeAll()
method. But this is just blind guessing without having tried it. So if you try and tell me it does not work, I'll delete my answer.
You can declare a new constructor that takes another array list argument(Do not change the previous constructor as other classes use it).
public Analyzer(final ExecutionDataStore executionData,
final ICoverageVisitor coverageVisitor, ArrayList<String> excludeClassPathArrayList) {
this.executionData = executionData;
this.coverageVisitor = coverageVisitor;
this.stringPool = new StringPool();
this.excludeClassPathArrayList = excludeClassPathArrayList;
}
Then modify method analyzeAll(final InputStream input, final String location)
, in ContentTypeDetector.CLASSFILE:
, you can do like this, if location contains exclude class path in arrary list, ignore them just like all other content types(return 0
).
mvn clean install
to recompile the jacoco source code.
You can see excluded classes also exclude from generated report. As the implementation is very simple so I do not provide code example.