title: How can I verify the minimum coverage with some excluded classes and with the jacoco plugin?
body: <p>I need to check the minimum coverage with the new jacoco task</p>
  
  <p><strong>jacocoTestCoverageVerification</strong></p>
  
  <p>This task is available with in the 3.4.1 gradle release and with the jacoco plugin >= 0.6.3</p>
  
  <p>I could run another task that generates an html report with the branch coverage but now I want to use that number to make the build fail.</p>
  
  <p>This is my code</p>
  
  <pre><code>buildscript {
      ext {
          ....
      }
      repositories {
          mavenCentral()
          maven {
              ....
          }
      }
      dependencies {
          .....
      }
  }
  
  
  apply plugin: 'java'
  apply plugin: 'eclipse'
  apply plugin: 'idea'
  apply plugin: 'jacoco'
  
  jar {
      baseName = "coverage-test"
  }
  
  
  dependencies {
      // my dependencies
  }
  
  
  eclipse {
      classpath {
           containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER')
           containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8'
      }
  }
  
  wrapper {
      gradleVersion = '3.4.1'
  }
  
  jacoco {
      toolVersion = '0.7.9'
  }
  
  jacocoTestReport {
      reports {
          xml.enabled false
          csv.enabled false
      }    
      group = "Reporting"
      description = "Generate Jacoco coverage reports after running tests."
      additionalSourceDirs = files(sourceSets.main.allJava.srcDirs)
  
      afterEvaluate {
          classDirectories = files(classDirectories.files.collect {
              fileTree(
                  dir: it,
                  excludes: 
                  [
                          'com/jacoco/dto/**',
                          'com/jacoco/configs/**', 
                          //and others
                  ])
          })
      }
  }
  
  jacocoTestCoverageVerification {
  
      //I tried this and it didn't work
  
    //   classDirectories = files(classDirectories.files.collect {
    //   fileTree(
    //    dir: it,
          // excludes: 
          // [
          //      'com/jacoco/dto/**',
          //      'com/jacoco/configs/**', 
          //      //and others
          // ])
    //   })
  
      violationRules {
          rule {
              //Also tried this and it didn't work
  
             // excludes = ['com/jacoco/dto/**', ...]
  
              limit {
                  counter = 'BRANCH'
                  minimum = 0.8
              }
          }
      }
  }
  check.dependsOn jacocoTestCoverageVerification
  </code></pre>
  
  <p>With <strong>classDirectories</strong> I get the following error <em>Cannot get property 'files' on null object</em>. And with the second option (only <strong>excludes</strong>), the build run smoothly but It doesn't exclude any class.</p>