title: Configuring Repositories for All Projects in Gradle
body: <p>I am trying to configure repositories for all subprojects.</p>
  <p>I have the main <code>build.gradle</code>:</p>
  <pre><code>buildscript {
      repositories {
          mavenLocal()
          mavenCentral()
          google()
          jcenter()
          ...
      }
      dependencies {
          // NOTE: Do not place your application dependencies here; they belong
          // in the individual module build.gradle files
      }
  }
  
  plugins {
      id 'base'
  }
  
  allprojects {
      apply plugin: 'base'
  
      repositories {
          mavenLocal()
          mavenCentral()
          google()
          jcentre()
          ...
      }
  
      wrapper{
          gradleVersion = '6.5.1'
          distributionType = Wrapper.DistributionType.ALL
      }
  
      dependencies {
          // NOTE: Do not place your application dependencies here; they belong
          // in the individual module build.gradle files
      }
  }
  </code></pre>
  <p>In the subprojects <code>build.gradle</code> I just have:</p>
  <pre><code>...
  
  dependencies {
      implementation ....
  }
  </code></pre>
  <p>I am getting:</p>
  <pre><code>Execution failed for task ':compileJava'.
  &gt; Could not resolve all files for configuration ':compileClasspath'.
     &gt; Cannot resolve external dependency .... because no repositories are defined.
       Required by:
           project :
  </code></pre>
  <p>I want to define <code>repositories</code> once in the main file as these do not change in subprojects.</p>
  <hr />
  <p>In the <code>settings.gradle</code> of the main project I have:</p>
  <pre><code>rootProject.name = 'main-project-name'
  
  include 'sub-project-name'
  
  </code></pre>
  <p>And in the <code>settings.gradle</code> of the sub project I have:</p>
  <pre><code>rootProject.name = 'sub-project-name'
  </code></pre>