同一文件中"应用自:"中的 gradle 访问权限属性



Error:(12, 0) Cannot get property 'kotlin' on extra properties extension as it does not exist

我的配置文件:buildsystem/configurations.gradle

ext {
    android = [
            buildToolsVersion: "26.0.2",
            minSdkVersion    : 23,
            targetSdkVersion : 27,
            compileSdkVersion: 27
    ]
    kotlin = [
            version      : '1.2.21',
            serialization: '0.4.1'
    ]
}

顶级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
}

如何从configurations.gradle文件中引用kotlin数组?我已经尝试了上面的project.ext.kotlin.versionext.kotlin.versionkotlin.version。这一定是如此明显,以至于我只是缺少一些东西。如果我更深入地进入子模型构建文件,我可以按照我的期望来引用所有内容。

buildscript块是其自己的脚本。处理此操作的一种方法是在buildscript块中应用脚本插件:

buildscript {
  apply from: 'buildsystem/configurations.gradle'
  // ... rest of buildscript configuration

最新更新