Fix inter-project IC with new MPP for JS/JVM targets
#KT-26275 Fixed #KT-29966 Fixed
This commit is contained in:
+1
-1
@@ -24,7 +24,7 @@ class IncrementalModuleInfo(
|
|||||||
val dirToModule: Map<File, IncrementalModuleEntry>,
|
val dirToModule: Map<File, IncrementalModuleEntry>,
|
||||||
val nameToModules: Map<String, Set<IncrementalModuleEntry>>,
|
val nameToModules: Map<String, Set<IncrementalModuleEntry>>,
|
||||||
val jarToClassListFile: Map<File, File>,
|
val jarToClassListFile: Map<File, File>,
|
||||||
// only for js
|
// only for js and mpp
|
||||||
val jarToModule: Map<File, IncrementalModuleEntry>
|
val jarToModule: Map<File, IncrementalModuleEntry>
|
||||||
) : Serializable {
|
) : Serializable {
|
||||||
companion object {
|
companion object {
|
||||||
|
|||||||
+5
@@ -91,6 +91,11 @@ abstract class ModulesApiHistoryBase(protected val modulesInfo: IncrementalModul
|
|||||||
|
|
||||||
class ModulesApiHistoryJvm(modulesInfo: IncrementalModuleInfo) : ModulesApiHistoryBase(modulesInfo) {
|
class ModulesApiHistoryJvm(modulesInfo: IncrementalModuleInfo) : ModulesApiHistoryBase(modulesInfo) {
|
||||||
override fun getBuildHistoryFilesForJar(jar: File): Either<Set<File>> {
|
override fun getBuildHistoryFilesForJar(jar: File): Either<Set<File>> {
|
||||||
|
val moduleInfoFromJar = modulesInfo.jarToModule[jar]
|
||||||
|
if (moduleInfoFromJar != null) {
|
||||||
|
return Either.Success(setOf(moduleInfoFromJar.buildHistoryFile))
|
||||||
|
}
|
||||||
|
|
||||||
val classListFile = modulesInfo.jarToClassListFile[jar] ?: return Either.Error("Unknown jar: $jar")
|
val classListFile = modulesInfo.jarToClassListFile[jar] ?: return Either.Error("Unknown jar: $jar")
|
||||||
if (!classListFile.isFile) return Either.Error("Class list file does not exist $classListFile")
|
if (!classListFile.isFile) return Either.Error("Class list file does not exist $classListFile")
|
||||||
|
|
||||||
|
|||||||
+39
-4
@@ -10,10 +10,7 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.NativeOutputKind
|
|||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.UnusedSourceSetsChecker
|
import org.jetbrains.kotlin.gradle.plugin.mpp.UnusedSourceSetsChecker
|
||||||
import org.jetbrains.kotlin.gradle.plugin.sources.METADATA_CONFIGURATION_NAME_SUFFIX
|
import org.jetbrains.kotlin.gradle.plugin.sources.METADATA_CONFIGURATION_NAME_SUFFIX
|
||||||
import org.jetbrains.kotlin.gradle.plugin.sources.SourceSetConsistencyChecks
|
import org.jetbrains.kotlin.gradle.plugin.sources.SourceSetConsistencyChecks
|
||||||
import org.jetbrains.kotlin.gradle.util.checkBytecodeContains
|
import org.jetbrains.kotlin.gradle.util.*
|
||||||
import org.jetbrains.kotlin.gradle.util.isWindows
|
|
||||||
import org.jetbrains.kotlin.gradle.util.modify
|
|
||||||
import org.jetbrains.kotlin.gradle.util.testResolveAllConfigurations
|
|
||||||
import org.jetbrains.kotlin.konan.target.CompilerOutputKind
|
import org.jetbrains.kotlin.konan.target.CompilerOutputKind
|
||||||
import org.jetbrains.kotlin.konan.target.HostManager
|
import org.jetbrains.kotlin.konan.target.HostManager
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
@@ -1552,4 +1549,42 @@ class NewMultiplatformIT : BaseGradleIT() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testIncrementalCompilation() = with(Project("new-mpp-jvm-js-ic", gradleVersion)) {
|
||||||
|
build("build") {
|
||||||
|
assertSuccessful()
|
||||||
|
}
|
||||||
|
|
||||||
|
val libCommonClassKt = projectDir.getFileByName("LibCommonClass.kt")
|
||||||
|
val libCommonClassJsKt = projectDir.getFileByName("LibCommonClassJs.kt")
|
||||||
|
libCommonClassJsKt.modify { it.checkedReplace("platform = \"js\"", "platform = \"Kotlin/JS\"") }
|
||||||
|
|
||||||
|
val libCommonClassJvmKt = projectDir.getFileByName("LibCommonClassJvm.kt")
|
||||||
|
libCommonClassJvmKt.modify { it.checkedReplace("platform = \"jvm\"", "platform = \"Kotlin/JVM\"") }
|
||||||
|
build("build") {
|
||||||
|
assertSuccessful()
|
||||||
|
assertCompiledKotlinSources(project.relativize(libCommonClassKt, libCommonClassJsKt, libCommonClassJvmKt))
|
||||||
|
}
|
||||||
|
|
||||||
|
val libJvmPlatformUtilKt = projectDir.getFileByName("libJvmPlatformUtil.kt")
|
||||||
|
libJvmPlatformUtilKt.modify {
|
||||||
|
it.checkedReplace("fun libJvmPlatformUtil", "inline fun libJvmPlatformUtil")
|
||||||
|
}
|
||||||
|
build("build") {
|
||||||
|
assertSuccessful()
|
||||||
|
val useLibJvmPlatformUtilKt = projectDir.getFileByName("useLibJvmPlatformUtil.kt")
|
||||||
|
assertCompiledKotlinSources(project.relativize(libJvmPlatformUtilKt, useLibJvmPlatformUtilKt))
|
||||||
|
}
|
||||||
|
|
||||||
|
val libJsPlatformUtilKt = projectDir.getFileByName("libJsPlatformUtil.kt")
|
||||||
|
libJsPlatformUtilKt.modify {
|
||||||
|
it.checkedReplace("fun libJsPlatformUtil", "inline fun libJsPlatformUtil")
|
||||||
|
}
|
||||||
|
build("build") {
|
||||||
|
assertSuccessful()
|
||||||
|
val useLibJsPlatformUtilKt = projectDir.getFileByName("useLibJsPlatformUtil.kt")
|
||||||
|
assertCompiledKotlinSources(project.relativize(libJsPlatformUtilKt, useLibJsPlatformUtilKt))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
apply from: "$rootDir/configure-targets.gradle"
|
||||||
|
|
||||||
|
kotlin.sourceSets.commonMain {
|
||||||
|
dependencies {
|
||||||
|
implementation project(":lib")
|
||||||
|
}
|
||||||
|
}
|
||||||
+8
@@ -0,0 +1,8 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
|
* that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
expect class AppCommonClass {
|
||||||
|
val platform: String
|
||||||
|
}
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
|
* that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class AppCommonDummy
|
||||||
+8
@@ -0,0 +1,8 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
|
* that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
actual class AppCommonClass {
|
||||||
|
actual val platform = "js"
|
||||||
|
}
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
|
* that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class AppJsDummy
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
|
* that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
fun useLibJsPlatformUtil() = libJsPlatformUtil()
|
||||||
+8
@@ -0,0 +1,8 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
|
* that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
actual class AppCommonClass {
|
||||||
|
actual val platform = "jvm"
|
||||||
|
}
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
|
* that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class AppJvmDummy
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
|
* that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
fun useLibJvmPlatformUtil() = libJvmPlatformUtil()
|
||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenLocal()
|
||||||
|
jcenter()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
subprojects {
|
||||||
|
repositories {
|
||||||
|
mavenLocal()
|
||||||
|
jcenter()
|
||||||
|
}
|
||||||
|
}
|
||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
apply plugin: "kotlin-multiplatform"
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
targets {
|
||||||
|
fromPreset(presets.jvm, 'jvm')
|
||||||
|
fromPreset(presets.js, 'js')
|
||||||
|
}
|
||||||
|
sourceSets {
|
||||||
|
commonMain {
|
||||||
|
dependencies {
|
||||||
|
implementation 'org.jetbrains.kotlin:kotlin-stdlib-common'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
jvmMain {
|
||||||
|
dependencies {
|
||||||
|
implementation 'org.jetbrains.kotlin:kotlin-stdlib'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
jsMain {
|
||||||
|
dependencies {
|
||||||
|
implementation 'org.jetbrains.kotlin:kotlin-stdlib-js'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
apply from: "$rootDir/configure-targets.gradle"
|
||||||
+8
@@ -0,0 +1,8 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
|
* that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
expect class LibCommonClass {
|
||||||
|
val platform: String
|
||||||
|
}
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
|
* that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class LibCommonDummy
|
||||||
+8
@@ -0,0 +1,8 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
|
* that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
actual class LibCommonClass {
|
||||||
|
actual val platform = "js"
|
||||||
|
}
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
|
* that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class LibJsDummy
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
|
* that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
fun libJsPlatformUtil(): Int = 0
|
||||||
+8
@@ -0,0 +1,8 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
|
* that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
actual class LibCommonClass {
|
||||||
|
actual val platform = "jvm"
|
||||||
|
}
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
|
* that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class LibJvmDummy
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
|
* that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
fun libJvmPlatformUtil(): Int = 0
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
include ':app', ':lib'
|
||||||
+12
@@ -20,6 +20,7 @@ import org.gradle.api.Project
|
|||||||
import org.gradle.api.Task
|
import org.gradle.api.Task
|
||||||
import org.gradle.api.invocation.Gradle
|
import org.gradle.api.invocation.Gradle
|
||||||
import org.gradle.api.plugins.JavaPluginConvention
|
import org.gradle.api.plugins.JavaPluginConvention
|
||||||
|
import org.gradle.api.tasks.bundling.AbstractArchiveTask
|
||||||
import org.gradle.jvm.tasks.Jar
|
import org.gradle.jvm.tasks.Jar
|
||||||
import org.jetbrains.kotlin.build.JvmSourceRoot
|
import org.jetbrains.kotlin.build.JvmSourceRoot
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
||||||
@@ -29,8 +30,10 @@ import org.jetbrains.kotlin.cli.common.arguments.K2MetadataCompilerArguments
|
|||||||
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
|
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
|
||||||
import org.jetbrains.kotlin.daemon.client.CompileServiceSession
|
import org.jetbrains.kotlin.daemon.client.CompileServiceSession
|
||||||
import org.jetbrains.kotlin.daemon.common.*
|
import org.jetbrains.kotlin.daemon.common.*
|
||||||
|
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||||
import org.jetbrains.kotlin.gradle.plugin.internal.state.TaskLoggers
|
import org.jetbrains.kotlin.gradle.plugin.internal.state.TaskLoggers
|
||||||
import org.jetbrains.kotlin.gradle.logging.kotlinDebug
|
import org.jetbrains.kotlin.gradle.logging.kotlinDebug
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
|
||||||
import org.jetbrains.kotlin.gradle.tasks.*
|
import org.jetbrains.kotlin.gradle.tasks.*
|
||||||
import org.jetbrains.kotlin.gradle.utils.newTmpFile
|
import org.jetbrains.kotlin.gradle.utils.newTmpFile
|
||||||
import org.jetbrains.kotlin.gradle.utils.relativeToRoot
|
import org.jetbrains.kotlin.gradle.utils.relativeToRoot
|
||||||
@@ -206,6 +209,15 @@ internal open class GradleCompilerRunner(protected val task: Task) {
|
|||||||
project.tasks.withType(InspectClassesForMultiModuleIC::class.java).forEach { task ->
|
project.tasks.withType(InspectClassesForMultiModuleIC::class.java).forEach { task ->
|
||||||
jarToClassListFile[File(task.archivePath)] = task.classesListFile
|
jarToClassListFile[File(task.archivePath)] = task.classesListFile
|
||||||
}
|
}
|
||||||
|
project.extensions.findByType(KotlinMultiplatformExtension::class.java)?.let { kotlinExt ->
|
||||||
|
for (target in kotlinExt.targets) {
|
||||||
|
val mainCompilation = target.compilations.findByName(KotlinCompilation.MAIN_COMPILATION_NAME) ?: continue
|
||||||
|
val kotlinTask = mainCompilation.compileKotlinTask as? AbstractKotlinCompile<*> ?: continue
|
||||||
|
val module = IncrementalModuleEntry(project.path, kotlinTask.moduleName, project.buildDir, kotlinTask.buildHistoryFile)
|
||||||
|
val jarTask = project.tasks.findByName(target.artifactsTaskName) as? AbstractArchiveTask ?: continue
|
||||||
|
jarToModule[jarTask.archivePath] = module
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return IncrementalModuleInfo(
|
return IncrementalModuleInfo(
|
||||||
|
|||||||
Reference in New Issue
Block a user