title: Gradle not recognizing plugin tasks from applied child script
body: <p>I would really like to modularize my script into multiple parts (test, default, documentation, android) sections. But I have problems when I try to apply child scripts to parent script...</p>
  
  <p>This is my child script (IDE is not complaining at this point)</p>
  
  <pre><code>import io.gitlab.arturbosch.detekt.Detekt
  
  
  task("hello").doLast {
      println("Hello World from plugins! :D")
  }
  
  
  tasks {
      val detekt by existing(Detekt::class) {
          reports {
              html {
                  val destination = "$buildDir/detekt"
              }
          }
      }
  }
  </code></pre>
  
  <p>But when I try to apply this script to main script:</p>
  
  <pre><code>apply(from = "tdd.gradle.kts")
  </code></pre>
  
  <p>I get folowing error:</p>
  
  <pre><code>    Script compilation errors:
  
    Line 01: import io.gitlab.arturbosch.detekt.Detekt
                    ^ Unresolved reference: io
  
    Line 10:  val detekt by existing(Detekt::class) {
                                     ^ Unresolved reference: Detekt
  
    Line 11:      reports {
               ^ Unresolved reference: reports
  
    Line 12:          html {
                ^ Unresolved reference: html
  </code></pre>
  
  <p>How can I solve this problem so that I can apply for example detekt plugin in child script and apply it in to parrent script?</p>