title: Gradle: Reading variable block from subproject in root project task
body: <p>I have been looking into how to define a block of variables in a small number of subprojects <code>build.gradle.kts</code>, and read these blocks from a task defined in the root project <code>build.gradle.kts</code>.</p>
  
  <p>SubProject1 <code>build.gradle.kts</code></p>
  
  <pre><code>dependencies {
      "implementation"("dependency.one:dep-one-api")
      ...
  }
  
  additionalProjectSpecificVars {
      val additionalOptions = listOf&lt;String&gt;("option1", "option2", ...)
      val additionalLocations = listOf&lt;String&gt;("$projectDir/location1/...", "$projectDir/location2/...")
  }
  </code></pre>
  
  <p>Root Project <code>build.gradle.kts</code></p>
  
  <pre><code>subprojects {
      if (project.name.endsWith("-wsdl")) {
          apply(plugin = "no.nils.wsdl2java")
  
          dependencies {
              ...
          }
  
          tasks.withType&lt;no.nils.wsdl2java.Wsdl2JavaTask&gt; {
              generatedWsdlDir = file("$projectDir/generatedsources")
              wsdlDir = file("$projectDir/wsdl")
              wsdlsToGenerate = gatherWsdlFiles()
          }
      }
  }
  
  fun Project.gatherWsdlFiles() : List&lt;ArrayList&lt;String&gt;&gt; {
  
      // 2-D Array
      var wsdlsToGenerateList = listOf&lt;ArrayList&lt;String&gt;&gt;()
  
      // Gather all the files in the WSDL directory
      val wsdlCollection = layout.files({
          file("$projectDir/wsdl").listFiles()
      })
  
      // Filter out only the .wsdl files
      val wsdlOnlyFiles: FileCollection = wsdlCollection.filter { file: File -&gt;
          file.name.endsWith(".wsdl")
      }
  
      // Iterate the files collection and add the cxf-parameters
      wsdlOnlyFiles.forEach { wsdl: File -&gt;
  
          val wsdlArray = listOf&lt;String&gt;(
                  "-xjc-Xnamespace-prefix",
                  "-xjc-XhashCode",
                  "-xjc-Xequals",
                  "-xjc-XtoString",
                  wsdl.name)
  
          wsdlsToGenerateList.plus(wsdlArray)
      }
  
  
      // Read and add the other options from the subprojects 
      // additionalProjectSpecificVars block here and add to
      // wsdlsToGenerateList list
  
  
      return wsdlsToGenerateList
  }
  </code></pre>
  
  <p>I've experimented with <code>project.ext</code>, <code>project.extra</code>, <code>gradle.ext</code> etc, but these seem to be if you want to read a property that has been set in the rootProject, rather than the reverse.</p>
  
  <p>Gradle v.6.2.2</p>