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.version
,ext.kotlin.version
和kotlin.version
。这一定是如此明显,以至于我只是缺少一些东西。如果我更深入地进入子模型构建文件,我可以按照我的期望来引用所有内容。
buildscript
块是其自己的脚本。处理此操作的一种方法是在buildscript
块中应用脚本插件:
buildscript {
apply from: 'buildsystem/configurations.gradle'
// ... rest of buildscript configuration