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
}
如何从kotlin
文件中引用configurations.gradle
数组?我已尝试过上面的内容,project.ext.kotlin.version
,ext.kotlin.version
和kotlin.version
。这必须是显而易见的,我只是遗漏了一些东西。如果我深入了解子模块构建文件,我可以像我期望的那样引用所有内容,但不是在这里。
答案 0 :(得分:2)
buildscript
块是它自己的脚本。解决此问题的一种方法是在buildscript
块中应用脚本插件:
buildscript {
apply from: 'buildsystem/configurations.gradle'
// ... rest of buildscript configuration