title: Task not found in root project
body: <p>I am confused by <code>gradle build lifecycle</code> for a few days. <a href="https://docs.gradle.org/current/userguide/build_lifecycle.html" rel="nofollow noreferrer">Refer</a> tells me </p>
  
  <blockquote>
    <p>A Gradle build has three distinct phases.</p>
    
    <ul>
    <li>Initialization</li>
    <li>Configuration</li>
    <li>Execution</li>
    </ul>
  </blockquote>
  
  <p><strong>Is task creation in the third step?</strong> If so, how does <code>gradle</code> find all <code>tasks</code> in a project object?</p>
  
  <p>Here is an example.</p>
  
  <pre><code> rootporject
         |----app
              |----build.gradle
              |----checkstyle.gradle
  </code></pre>
  
  <p>The <code>build.gradle</code> is as simple as normal.<code>checkstyle.gradle</code> file has a task. Here is its content.</p>
  
  <pre><code>apply plugin: 'checkstyle'
  
  task checkstyle(type:Checkstyle) {
      description 'Runs Checkstyle inspection against girl sourcesets.'
      group = 'Code Quality'
      configFile rootProject.file('checkstyle.xml')
      ignoreFailures = false
      showViolations true
      classpath = files()
      source 'src/main/java'
  }
  </code></pre>
  
  <p>After <code>./gradlew -q tasks</code>, there is no task <code>checkstyle</code>.</p>
  
  <p><strong>But if I remove the definition into <code>build.gradle</code>, I get it</strong>. </p>
  
  <p>Is there anything wrong?Thanks in advance.</p>
  
  <h1>Edit</h1>
  
  <p>From <a href="https://docs.gradle.org/current/dsl/org.gradle.api.Project.html" rel="nofollow noreferrer">doc</a></p>
  
  <blockquote>
    <p>There is a one-to-one relationship between a Project and a build.gradle file.</p>
  </blockquote>