Q:

Gradle access property from `apply from: ''` in same file

Error:(12, 0) Cannot get property 'kotlin' on extra properties extension as it does not exist
My config file: buildsystem/configurations.gradle
ext {
    android = [
            buildToolsVersion: "26.0.2",
            minSdkVersion    : 23,
            targetSdkVersion : 27,
            compileSdkVersion: 27
    ]

    kotlin = [
            version      : '1.2.21',
            serialization: '0.4.1'
    ]
}

Top level build.gradle
apply from: 'buildsystem/configurations.gradle'

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        //get kotlin version from configurations.gradle
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${rootProject.ext.kotlin.version}"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

How can I reference the kotlin array from the configurations.gradle file? I've tried what I have above, project.ext.kotlin.version, ext.kotlin.version, and just kotlin.version. This has to be so obvious that I'm just missing something. If I go deeper into submodule build files I can reference everything as I'd expect, but not here.

A:

The buildscript block is sort of its own script. One way to handle this is to apply the script plugin in the buildscript block:
buildscript {
  apply from: 'buildsystem/configurations.gradle'
  // ... rest of buildscript configuration

