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:
+10
@@ -577,4 +577,14 @@ open class Kapt3IT : Kapt3BaseIT() {
|
|||||||
|
|
||||||
testResolveAllConfigurations()
|
testResolveAllConfigurations()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testMPPKaptPresence() {
|
||||||
|
val project = Project("mpp-kapt-presence", directoryPrefix = "kapt2")
|
||||||
|
|
||||||
|
project.build("build") {
|
||||||
|
assertSuccessful()
|
||||||
|
assertTasksExecuted(":dac:jdk:kaptGenerateStubsKotlin", ":dac:jdk:compileKotlin")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+26
@@ -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()
|
||||||
|
}
|
||||||
|
}
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
apply plugin: 'org.jetbrains.kotlin.platform.common'
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile deps.kotlin.stdlib.common
|
||||||
|
}
|
||||||
+10
@@ -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
|
||||||
|
}
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
package test.abc
|
||||||
|
|
||||||
|
actual interface DocumentationService {
|
||||||
|
actual fun list(): List<Item>
|
||||||
|
}
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
package test.abc
|
||||||
|
|
||||||
|
expect interface DocumentationService {
|
||||||
|
fun list(): List<Item>
|
||||||
|
}
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
package test.abc
|
||||||
|
|
||||||
|
class Item
|
||||||
+2
@@ -0,0 +1,2 @@
|
|||||||
|
include ':dac'
|
||||||
|
include ':dac:jdk'
|
||||||
+3
-3
@@ -162,12 +162,12 @@ open class KotlinPlatformImplementationPluginBase(platformName: String) : Kotlin
|
|||||||
protected open fun addCommonSourceSetToPlatformSourceSet(commonSourceSet: Named, platformProject: Project) {
|
protected open fun addCommonSourceSetToPlatformSourceSet(commonSourceSet: Named, platformProject: Project) {
|
||||||
platformProject.whenEvaluated {
|
platformProject.whenEvaluated {
|
||||||
// At the point when the source set in the platform module is created, the task does not exist
|
// 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)
|
.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)!!
|
val commonSources = getKotlinSourceDirectorySetSafe(commonSourceSet)!!
|
||||||
if (platformTask != null) {
|
for (platformTask in platformTasks) {
|
||||||
platformTask.source(commonSources)
|
platformTask.source(commonSources)
|
||||||
platformTask.commonSourceSet += commonSources
|
platformTask.commonSourceSet += commonSources
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user