diff --git a/build.gradle b/build.gradle index 9ad2ad2f1e9..c85be955874 100644 --- a/build.gradle +++ b/build.gradle @@ -23,10 +23,6 @@ import org.jetbrains.kotlin.konan.* buildscript { apply from: "gradle/kotlinGradlePlugin.gradle" apply from: "gradle/kotlinNativeShared.gradle" - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-native-version:$konanVersion" - } } // Allows generating wrappers for the root build and all the samples during execution of the default 'wrapper' task. diff --git a/buildSrc/plugins/build.gradle b/buildSrc/plugins/build.gradle index 0c36965b293..8f111d10ab5 100644 --- a/buildSrc/plugins/build.gradle +++ b/buildSrc/plugins/build.gradle @@ -38,8 +38,23 @@ dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib:$buildKotlinVersion" compile "org.jetbrains.kotlin:kotlin-reflect:$buildKotlinVersion" compile group: 'com.ullink.slack', name: 'simpleslackapi', version: '0.6.0' - compile "org.jetbrains.kotlin:kotlin-native-shared:$sharedVersion" compile "org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.10.0" + + // Support composite build against kotlin-native-shared. + // Gradle cannot substitute a dependency in buildSrc by an included build. + // See: https://github.com/gradle/gradle/issues/3768. + // Thus we have to compile sources of the included shared once more + // and depend on them during buildSrc compilation. + // We don't add this dependency in the runtime scope because build scripts + // already depend on kotlin-native-shared and this dependency is correctly + // substituted by the included build. + if (hasProperty("sharedProjectPath")) { + compileOnly project(':shared') + } else { + // If there is no composite build against shared, add a dependency on a published jar. + compile "org.jetbrains.kotlin:kotlin-native-shared:$sharedVersion" + } + } rootProject.dependencies { diff --git a/buildSrc/settings.gradle b/buildSrc/settings.gradle index c2b26557d2d..2c422c764d5 100644 --- a/buildSrc/settings.gradle +++ b/buildSrc/settings.gradle @@ -15,3 +15,7 @@ */ include 'plugins' + +if (hasProperty("sharedProjectPath")) { + include 'shared' +} \ No newline at end of file diff --git a/buildSrc/shared/build.gradle.kts b/buildSrc/shared/build.gradle.kts new file mode 100644 index 00000000000..c2bc6653b6c --- /dev/null +++ b/buildSrc/shared/build.gradle.kts @@ -0,0 +1,27 @@ +/* + * Copyright 2010-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +plugins { + kotlin("jvm") +} + +val sharedProject = file(property("sharedProjectPath")!!).resolve("src") + +kotlin.sourceSets["main"].kotlin.srcDirs.add(sharedProject) + +dependencies { + implementation(kotlin("stdlib")) +} diff --git a/settings.gradle b/settings.gradle index f9cfe3b4461..7dd9b9548d8 100644 --- a/settings.gradle +++ b/settings.gradle @@ -49,3 +49,7 @@ if (hasProperty("kotlinProjectPath")) { } } } + +if (hasProperty("sharedProjectPath")) { + includeBuild(sharedProjectPath) +}