title: Purpose of buildscript block in Gradle
body: <p>I am new to Gradle and I am reading the documentation but I don't understand some parts of it. One of these parts is connected with <code>buildscript</code> block. What is its purpose?</p>
  
  
  
  <blockquote>
    <p>If your build script needs to use external libraries, you can add them to the script's classpath in the build script itself. You do this using the buildscript() method, passing in a closure which declares the build script classpath.</p>
  
  <pre class="lang-groovy prettyprint-override"><code>buildscript {
    repositories {
      mavenCentral()
    }
    dependencies {
      classpath group: 'commons-codec', name: 'commons-codec', version: '1.2'
    }
  }
  </code></pre>
  </blockquote>
  
  <p>Ok but what is the difference with:</p>
  
  <pre class="lang-groovy prettyprint-override"><code>repositories {
    mavenCentral()
  }
  dependencies {
    compile group: 'commons-codec', name: 'commons-codec', version: '1.2'
  }
  </code></pre>
  
  <p>For example, why it is necessary to use <code>buildscript</code>?</p>