Search in sources :

Example 1 with Rule

use of org.jacoco.report.check.Rule in project jacoco by jacoco.

the class CheckMojo method executeCheck.

private void executeCheck() throws MojoExecutionException {
    violations = false;
    final ReportSupport support = new ReportSupport(getLog());
    final List<Rule> checkerrules = new ArrayList<Rule>();
    for (final RuleConfiguration r : rules) {
        checkerrules.add(r.rule);
    }
    support.addRulesChecker(checkerrules, this);
    try {
        final IReportVisitor visitor = support.initRootVisitor();
        support.loadExecutionData(dataFile);
        support.processProject(visitor, getProject(), this.getIncludes(), this.getExcludes());
        visitor.visitEnd();
    } catch (final IOException e) {
        throw new MojoExecutionException("Error while checking code coverage: " + e.getMessage(), e);
    }
    if (violations) {
        if (this.haltOnFailure) {
            throw new MojoExecutionException(CHECK_FAILED);
        } else {
            this.getLog().warn(CHECK_FAILED);
        }
    } else {
        this.getLog().info(CHECK_SUCCESS);
    }
}
Also used : MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) ArrayList(java.util.ArrayList) Rule(org.jacoco.report.check.Rule) IOException(java.io.IOException) IReportVisitor(org.jacoco.report.IReportVisitor)

Aggregations

IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 IReportVisitor (org.jacoco.report.IReportVisitor)1 Rule (org.jacoco.report.check.Rule)1