title: Calling Gradle task for only one subproject
body: <p>How do I configure subprojects for Gradle and run a Gradle task from the <code>build.gradle</code> only for the current directory I'm executing the task from?</p>
  
  <p>For example, suppose I have two projects in a parent folder:</p>
  
  <ul>
  <li><code>root-project</code>
  
  <ul>
  <li><code>project-1</code></li>
  <li><code>project-2</code></li>
  </ul></li>
  <li><code>build.gradle</code></li>
  <li><code>settings.gradle</code></li>
  </ul>
  
  <p>I have project 1 and 2 included in the <code>settings.gradle</code> file:</p>
  
  <pre><code>include(
      'project-1',
      'project-2'
  )
  </code></pre>
  
  <p>I have a task configured in the <code>build.gradle</code> file that I would like to call. I've nested the tasks within a <code>subprojects{}</code> block:</p>
  
  <pre><code>subprojects {
      ...
      task check(type: JavaExec) {
          main = MAIN_CLASS
          classpath = sourceSets.main.runtimeClasspath
      }
      ...
  }
  </code></pre>
  
  <p>However, the <code>build.gradle</code> is run for all subprojects that way. </p>
  
  <p>How can I define all possible subprojects but only call a Gradle task for the current project I'm executing from (i.e., avoid calling the task for all subprojects)? I would like to do this with the current task name only (e.g., <code>gradle check</code>).</p>