title: Gradle: Making external plugin dependencies for the build script and normal dependencies available in subprojects
body: <p>how do I make external plugin dependencies for the build script and normal dependencies from the <code>build.gradle</code> file in the directory of the root project available in subprojects?</p>
  <p>For plugins used in the build script there is <code>buildscript</code> and für the other dependencies there is <code>allprojects</code>.</p>
  <p>Also, there is a <code>classpath</code> method, which I find documented nowhere. To which class it belongs or in what scope. There just is a deprecated and a non-deprecated example.</p>
  <p>The deprecated example is to find here under <a href="https://docs.gradle.org/current/userguide/plugins.html#sec:applying_plugins_buildscript" rel="nofollow noreferrer">https://docs.gradle.org/current/userguide/plugins.html#sec:applying_plugins_buildscript</a> It is deprecated because the use of <code>apply</code> and the example code is</p>
  <pre><code>buildscript {
      repositories {
          gradlePluginPortal()
      }
      dependencies {
          classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5'
      }
  }
  
  apply plugin: 'com.jfrog.bintray'
  </code></pre>
  <p>The non-deprecated example is to find here under <a href="https://docs.gradle.org/current/userguide/tutorial_using_tasks.html#sec:build_script_external_dependencies" rel="nofollow noreferrer">https://docs.gradle.org/current/userguide/tutorial_using_tasks.html#sec:build_script_external_dependencies</a> and the example code is this... (without apply in the closure)</p>
  <pre><code>buildscript {
      repositories {
          mavenCentral()
      }
      dependencies {
          classpath group: 'commons-codec', name: 'commons-codec', version: '1.2'
      }
  }
  </code></pre>
  <p>As I said, I can't find documentation for <code>classpath</code> so I don't know if it really needs the named argument list or just, for example <code>classpath &quot;commons-codec:commons-codec:1.2&quot;</code>.</p>
  <p>Also I want to have the other dependencies created by spring.initializr (<a href="http://start.spring.io" rel="nofollow noreferrer">http://start.spring.io</a>) in the subprojects. For the normal dependencies I read one should use <code>allprojects</code></p>
  <p>So my script would look something like this. It would be kind if you would correct my errors</p>
  <pre><code>buildscript {
      repositories {
        mavenCentral()
      }
      dependencies {
          classpath 'io.spring.gradle:dependency-management-plugin:0.5.3.RELEASE'
      }
  }
  
  allprojects {
    plugins {
      id 'java'
    }
  
    dependencies {
      testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
      testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
    }
  }
  </code></pre>
  <p>I don't really know where to put</p>
  <pre><code>ext {
      set('springCloudVersion', &quot;Hoxton.SR4&quot;)
  }
  
  group = 'com.microservicetest'
  version = '0.0.1-SNAPSHOT'
  sourceCompatibility = '11'
  
  repositories {
    mavenCentral()
  }
  
  test {
      useJUnitPlatform()
  }
  
  dependencyManagement {
      imports {
          mavenBom &quot;org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}&quot;
      }
  }
  </code></pre>
  <p>Original thread is here <a href="https://stackoverflow.com/questions/71114443/build-gradle-created-by-spring-initializr-error-message-on-import-function#comment125740321_71117396">build.gradle created by spring initializr error message on &quot;import&quot; function</a></p>
  <p>Thanks</p>