From 270a53ac8b953840763c23749c5998e8a17effcd Mon Sep 17 00:00:00 2001 From: Ilya Matveev Date: Wed, 24 Apr 2019 16:20:15 +0700 Subject: [PATCH] Fix composite build against shared Gradle executes buildSrc logic in a separate classloader. Thus we need to build sources of the composite shared in buildSrc and include them in runtime dependencies of the buildSrc:plugin project. --- buildSrc/plugins/build.gradle | 10 +++------- buildSrc/shared/build.gradle.kts | 2 +- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/buildSrc/plugins/build.gradle b/buildSrc/plugins/build.gradle index 8f111d10ab5..82996c1b9d3 100644 --- a/buildSrc/plugins/build.gradle +++ b/buildSrc/plugins/build.gradle @@ -43,13 +43,9 @@ dependencies { // 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') + // Thus we have to compile sources of the included shared once more to use it in buildSrc. + if (project.hasProperty("sharedProjectPath")) { + compile 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" diff --git a/buildSrc/shared/build.gradle.kts b/buildSrc/shared/build.gradle.kts index c2bc6653b6c..29b70fc5c32 100644 --- a/buildSrc/shared/build.gradle.kts +++ b/buildSrc/shared/build.gradle.kts @@ -20,7 +20,7 @@ plugins { val sharedProject = file(property("sharedProjectPath")!!).resolve("src") -kotlin.sourceSets["main"].kotlin.srcDirs.add(sharedProject) +kotlin.sourceSets["main"].kotlin.srcDirs(sharedProject) dependencies { implementation(kotlin("stdlib"))