title: How can I execute checkstyle whenever I build an Android app
body: <p>I'm trying to integrate checkstyle with an Android project - my build.gradle is below.  I'd like to basically see warnings identifying code that's missing documentation on build.  With this config, I see a gradle task named checkstyle that I can execute manually, but it's not called when I rebuild the project (even if I right-click the task and say execute on rebuild')</p>
  
  <p>I must be missing something, because it seems like others are having the exact opposite problem and are trying to prevent it from running on build.  What am I doing wrong?  </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>// Top-level build file where you can add configuration options common to all sub-projects/modules.
  
  buildscript {
      repositories {
          jcenter()
      }
      dependencies {
          classpath 'com.android.tools.build:gradle:2.1.2'
  
          // NOTE: Do not place your application dependencies here; they belong
          // in the individual module build.gradle files
      }
  }
  
  allprojects {
      repositories {
          jcenter()
      }
      apply plugin: 'checkstyle'
  
      task checkstyle(type: Checkstyle) {
          configFile file("${project.rootDir}/config/checkstyle/checkstyle.xml")
          source 'src'
          include '**/*.java'
          exclude '**/gen/**'
  
          reports {
              xml.enabled = true
          }
  
          classpath = files()
      }
  }
  
  task clean(type: Delete) {
      delete rootProject.buildDir
  }</code></pre>
  </div>
  </div>
  </p>