#137 Maven Report goal fails on missing classes directory

open
nobody
JaCoCo (32)
5
2012-08-16
2012-08-16
Jens
No

Version 0.5.9
Maven 3.0.4

The maven plugins fails, if the project contains only test classes and there fore the folder target/classes is missing.

Suggestion to quick fix the problem: check if the folder exists

IBundleCoverage createBundle() throws IOException {
final CoverageBuilder builder = new CoverageBuilder();
final Analyzer analyzer = new Analyzer(executionDataStore, builder);
final File classesDir = new File(getProject().getBuild()
.getOutputDirectory());

if( classDir.exists() == true ) {
final List<File> filesToAnalyze = getFilesToAnalyze(classesDir);

if( filesToAnalyze.size() != 0 ) {
for (final File file : filesToAnalyze) {
analyzer.analyzeAll(file);
}
} else {
log().info("no classes found to added for analyse");
}
} else {
log().info("no output folder found and noclassed added for analyse");
}

return builder.getBundle(getProject().getName());
}

I'm not sure if this will fix the problem in generell, because I do not know what happens if the CovarageBuilder contains no classes.

Kind Regards,

Jens

Discussion

  • Jens

    Jens - 2012-08-16
    • summary: Maven Report goals fails on missing classes directory --> Maven Report goal fails on missing classes directory
     
  • Marc R. Hoffmann

    So why do you want to create a coverage report for a module that only contains test code?

    I agree that error handling can be improved.

     
  • Jens

    Jens - 2012-08-18

    Hello, in our setup we do not have the test code in the same project as the production code. So there will be one test project for some other project. We build and test all project with one reactor, in this case the report will try to collect coverage data for the test project.
    I can skip coverage report for the test project, that one solution, but in that case I have to change the pom. I want to avoid this, if I can.