title: How to execute task in Gradle?
body: <p>I have the following project structure:</p>
  
  <ul>
  <li>application
  <ul>
  <li>build.gradle</li>
  </ul></li>
  <li>build.gradle</li>
  <li>settings.gradle</li>
  </ul>
  
  <p><em>application/build.gradle:</em></p>
  
  <pre><code>apply plugin: 'java'
  </code></pre>
  
  <p><em>settings.gradle:</em></p>
  
  <pre><code>include ':application'
  </code></pre>
  
  <p><em>build.gradle:</em></p>
  
  <pre><code>task custom &lt;&lt; {
    project.tasks.getByName("build").execute()
  }
  </code></pre>
  
  <p>So I want to execute task "build" inside task "custom".
  But when I run "gradle custom" the result is:</p>
  
  <pre><code>:custom FAILED
  
  FAILURE: Build failed with an exception.
  
  * Where:
  Build file '/tmp/test/build.gradle' line: 3
  
  * What went wrong:
  Execution failed for task ':custom'.
  &gt; Task with name 'build' not found in root project 'test'.
  
  * Try:
  Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
  
  BUILD FAILED
  
  Total time: 1.183 secs
  </code></pre>
  
  <p>How I can execute the task "build" inside task "custom" ?</p>