我有一个Kotlin多项目,其大致结构如下:
+-----------------+
| |
| Main |
| Kotlin 1.2 |
| |
| |
| |
+--+------------+-+
| |
| |
+------------v----+ +---v--------------+
| | | |
| Sub 1 | | Sub 2..n |
| Kotlin 1.3 | | Kotlin 1.2 |
| | | |
| | | |
| | | |
| | | |
+-----------------+ +------------------+
我需要用org.jetbrains.kotlin:kotlin-compiler-embeddable:1.3.*
来编译Sub 1,而用org.jetbrains.kotlin:kotlin-compiler-embeddable:1.2.*
来编译所有其他。
主要gradle文件如下所示:
buildscript {
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.71"
}
}
apply plugin: "kotlin"
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.2.71"
// ... more
}
使用1.3项目的sub gradle文件:
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.61"
}
}
plugins {
id "application"
}
apply plugin: "java"
apply plugin: "kotlin"
java {
disableAutoTargetJvm()
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.61"
// ... more
}
正在运行./gradlew server:dependencies | grep 1.2.71
,但是仍然显示kotlin编译器的依赖关系为1.2:
| +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.2.71 -> 1.3.61 (*)
| | +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.2.71 -> 1.3.61 (*)
| | +--- org.jetbrains.kotlin:kotlin-reflect:1.2.71 -> 1.3.61 (*)
| | | +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.2.71 -> 1.3.61 (*)
| | | +--- org.jetbrains.kotlin:kotlin-reflect:1.2.71 -> 1.3.61
| | +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.2.71 -> 1.3.61 (*)
| | +--- org.jetbrains.kotlin:kotlin-reflect:1.2.71 -> 1.3.61 (*)
| +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.2.71 -> 1.3.61 (*)
| | +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.2.71 -> 1.3.61 (*)
| | +--- org.jetbrains.kotlin:kotlin-reflect:1.2.71 -> 1.3.61 (*)
\--- org.jetbrains.kotlin:kotlin-compiler-embeddable:1.2.71
+--- org.jetbrains.kotlin:kotlin-stdlib:1.2.71
| +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.2.71
+--- org.jetbrains.kotlin:kotlin-script-runtime:1.2.71
\--- org.jetbrains.kotlin:kotlin-reflect:1.2.71
\--- org.jetbrains.kotlin:kotlin-stdlib:1.2.71 (*)
\--- org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.2.71
| | | +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.2.71 -> 1.3.61 (*)
| | | +--- org.jetbrains.kotlin:kotlin-reflect:1.2.71 -> 1.3.61
| | +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.2.71 -> 1.3.61 (*)
| | +--- org.jetbrains.kotlin:kotlin-reflect:1.2.71 -> 1.3.61 (*)
| +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.2.71 -> 1.3.61 (*)
| | +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.2.71 -> 1.3.61 (*)
| | +--- org.jetbrains.kotlin:kotlin-reflect:1.2.71 -> 1.3.61 (*)
该子项目如何覆盖kotlin编译器版本?