Attach expect sources to all source set tasks (KT-26977)

If kapt is enabled, there are several Kotlin compilation tasks for one source set (stub generator + compile). We should attach the expect sources to all of them.
This commit is contained in:
Yan Zhulanow
2019-02-04 23:03:00 +03:00
parent 1c824655d4
commit 770a2e3f2d
9 changed files with 69 additions and 3 deletions
@@ -577,4 +577,14 @@ open class Kapt3IT : Kapt3BaseIT() {
testResolveAllConfigurations()
}
@Test
fun testMPPKaptPresence() {
val project = Project("mpp-kapt-presence", directoryPrefix = "kapt2")
project.build("build") {
assertSuccessful()
assertTasksExecuted(":dac:jdk:kaptGenerateStubsKotlin", ":dac:jdk:compileKotlin")
}
}
}
@@ -0,0 +1,26 @@
buildscript {
ext.deps = [
'kotlin': [
'stdlib': [
'common': "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlin_version",
'jdk': "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version",
],
],
]
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
mavenLocal()
mavenCentral()
}
}
@@ -0,0 +1,5 @@
apply plugin: 'org.jetbrains.kotlin.platform.common'
dependencies {
compile deps.kotlin.stdlib.common
}
@@ -0,0 +1,10 @@
apply plugin: 'org.jetbrains.kotlin.platform.jvm'
apply plugin: 'kotlin-kapt'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
dependencies {
expectedBy project(':dac')
implementation deps.kotlin.stdlib.jdk
}
@@ -0,0 +1,5 @@
package test.abc
actual interface DocumentationService {
actual fun list(): List<Item>
}
@@ -0,0 +1,5 @@
package test.abc
expect interface DocumentationService {
fun list(): List<Item>
}
@@ -162,12 +162,12 @@ open class KotlinPlatformImplementationPluginBase(platformName: String) : Kotlin
protected open fun addCommonSourceSetToPlatformSourceSet(commonSourceSet: Named, platformProject: Project) {
platformProject.whenEvaluated {
// At the point when the source set in the platform module is created, the task does not exist
val platformTask = platformProject.tasks
val platformTasks = platformProject.tasks
.withType(AbstractKotlinCompile::class.java)
.singleOrNull { it.sourceSetName == commonSourceSet.name } // TODO use strict check once this code is not run in K/N
.filter { it.sourceSetName == commonSourceSet.name } // TODO use strict check once this code is not run in K/N
val commonSources = getKotlinSourceDirectorySetSafe(commonSourceSet)!!
if (platformTask != null) {
for (platformTask in platformTasks) {
platformTask.source(commonSources)
platformTask.commonSourceSet += commonSources
}