Store module info under own module name for incremental compilation
#KT-51463 Fixed
This commit is contained in:
+36
-2
@@ -666,6 +666,38 @@ open class KotlinAndroid70GradleIT : KotlinAndroid36GradleIT() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testAndroidWithKaptIncremental() {
|
||||||
|
val project = Project("AndroidIncrementalMultiModule")
|
||||||
|
val options = defaultBuildOptions().copy(incremental = true)
|
||||||
|
project.setupWorkingDir().also {
|
||||||
|
project.gradleBuildScript("app").modify {
|
||||||
|
"""
|
||||||
|
apply plugin: 'org.jetbrains.kotlin.kapt'
|
||||||
|
$it
|
||||||
|
""".trimIndent()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
project.build(":app:testDebugUnitTest", options = options) {
|
||||||
|
assertSuccessful()
|
||||||
|
}
|
||||||
|
|
||||||
|
project.projectDir
|
||||||
|
.resolve("app/src/main/kotlin/com/example/KotlinActivity.kt")
|
||||||
|
.appendText(
|
||||||
|
"""
|
||||||
|
{
|
||||||
|
private val x = 1
|
||||||
|
}
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
|
||||||
|
project.build(":app:testDebugUnitTest", options = options) {
|
||||||
|
assertSuccessful()
|
||||||
|
assertNotContains("Non-incremental compilation will be performed")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testNamespaceDSLInsteadOfPackageAttributeInManifest() {
|
fun testNamespaceDSLInsteadOfPackageAttributeInManifest() {
|
||||||
val project = Project("AndroidExtensionsProjectAGP7")
|
val project = Project("AndroidExtensionsProjectAGP7")
|
||||||
@@ -792,7 +824,8 @@ abstract class KotlinAndroid3GradleIT : AbstractKotlinAndroidGradleTests() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
kotlin { android("android") { } }
|
kotlin { android("android") { } }
|
||||||
""".trimIndent())
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
|
||||||
build("help") {
|
build("help") {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
@@ -971,7 +1004,8 @@ fun getSomething() = 10
|
|||||||
|
|
|
|
||||||
|androidExtensions {
|
|androidExtensions {
|
||||||
| experimental = true
|
| experimental = true
|
||||||
|}
|
|
|
||||||
|
}
|
||||||
""".trimMargin()
|
""".trimMargin()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+2
@@ -41,6 +41,7 @@ class KotlinJvmApiTest : KGPBaseTest() {
|
|||||||
it.source("src/main")
|
it.source("src/main")
|
||||||
it.multiPlatformEnabled.set(false)
|
it.multiPlatformEnabled.set(false)
|
||||||
it.moduleName.set("main")
|
it.moduleName.set("main")
|
||||||
|
it.ownModuleName.set("main")
|
||||||
it.sourceSetName.set("main")
|
it.sourceSetName.set("main")
|
||||||
it.useModuleDetection.set(false)
|
it.useModuleDetection.set(false)
|
||||||
it.destinationDirectory.fileValue(new File(project.buildDir, "fooOutput"))
|
it.destinationDirectory.fileValue(new File(project.buildDir, "fooOutput"))
|
||||||
@@ -94,6 +95,7 @@ class KotlinJvmApiTest : KGPBaseTest() {
|
|||||||
it.source("src/main")
|
it.source("src/main")
|
||||||
it.multiPlatformEnabled.set(false)
|
it.multiPlatformEnabled.set(false)
|
||||||
it.moduleName.set("main")
|
it.moduleName.set("main")
|
||||||
|
it.ownModuleName.set("main")
|
||||||
it.sourceSetName.set("main")
|
it.sourceSetName.set("main")
|
||||||
it.useModuleDetection.set(false)
|
it.useModuleDetection.set(false)
|
||||||
it.destinationDirectory.fileValue(new File(project.buildDir, "fooOutput"))
|
it.destinationDirectory.fileValue(new File(project.buildDir, "fooOutput"))
|
||||||
|
|||||||
+1
@@ -21,4 +21,5 @@ dependencies {
|
|||||||
implementation project(":libJvmClassesOnly")
|
implementation project(":libJvmClassesOnly")
|
||||||
implementation project(":libAndroid")
|
implementation project(":libAndroid")
|
||||||
implementation project(":libAndroidClassesOnly")
|
implementation project(":libAndroidClassesOnly")
|
||||||
|
testImplementation "junit:junit:4.13.2"
|
||||||
}
|
}
|
||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
package com.example
|
||||||
|
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.Assert.*
|
||||||
|
/*
|
||||||
|
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class UnitTest {
|
||||||
|
@Test
|
||||||
|
fun isCorrect() {
|
||||||
|
assertEquals(4, 2 + 2)
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
-2
@@ -295,7 +295,7 @@ internal open class GradleCompilerRunner(
|
|||||||
if (task is AbstractKotlinCompile<*>) {
|
if (task is AbstractKotlinCompile<*>) {
|
||||||
val module = IncrementalModuleEntry(
|
val module = IncrementalModuleEntry(
|
||||||
project.path,
|
project.path,
|
||||||
task.moduleName.get(),
|
task.ownModuleName.get(),
|
||||||
project.buildDir,
|
project.buildDir,
|
||||||
task.buildHistoryFile.get().asFile,
|
task.buildHistoryFile.get().asFile,
|
||||||
task.abiSnapshotFile.get().asFile
|
task.abiSnapshotFile.get().asFile
|
||||||
@@ -327,7 +327,7 @@ internal open class GradleCompilerRunner(
|
|||||||
val kotlinTask = mainCompilation.compileKotlinTask as? AbstractKotlinCompile<*> ?: continue
|
val kotlinTask = mainCompilation.compileKotlinTask as? AbstractKotlinCompile<*> ?: continue
|
||||||
val module = IncrementalModuleEntry(
|
val module = IncrementalModuleEntry(
|
||||||
project.path,
|
project.path,
|
||||||
kotlinTask.moduleName.get(),
|
kotlinTask.ownModuleName.get(),
|
||||||
project.buildDir,
|
project.buildDir,
|
||||||
kotlinTask.buildHistoryFile.get().asFile,
|
kotlinTask.buildHistoryFile.get().asFile,
|
||||||
kotlinTask.abiSnapshotFile.get().asFile
|
kotlinTask.abiSnapshotFile.get().asFile
|
||||||
|
|||||||
+3
@@ -274,6 +274,9 @@ abstract class AbstractKotlinCompile<T : CommonCompilerArguments> @Inject constr
|
|||||||
@get:Internal
|
@get:Internal
|
||||||
val startParameters = BuildMetricsReporterService.getStartParameters(project)
|
val startParameters = BuildMetricsReporterService.getStartParameters(project)
|
||||||
|
|
||||||
|
@get:Input
|
||||||
|
abstract val ownModuleName: Property<String>
|
||||||
|
|
||||||
@get:Internal
|
@get:Internal
|
||||||
internal abstract val buildMetricsReporterService: Property<BuildMetricsReporterService?>
|
internal abstract val buildMetricsReporterService: Property<BuildMetricsReporterService?>
|
||||||
|
|
||||||
|
|||||||
+1
@@ -94,6 +94,7 @@ internal abstract class AbstractKotlinCompileConfig<TASK : AbstractKotlinCompile
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
task.moduleName.set(providers.provider { compilation.moduleName })
|
task.moduleName.set(providers.provider { compilation.moduleName })
|
||||||
|
task.ownModuleName.set(project.provider { compilation.ownModuleName })
|
||||||
task.sourceSetName.value(providers.provider { compilation.compilationPurpose })
|
task.sourceSetName.value(providers.provider { compilation.compilationPurpose })
|
||||||
task.multiPlatformEnabled.value(
|
task.multiPlatformEnabled.value(
|
||||||
providers.provider {
|
providers.provider {
|
||||||
|
|||||||
+2
-2
@@ -76,9 +76,9 @@ internal open class BaseKotlinCompileConfig<TASK : KotlinCompile> : AbstractKotl
|
|||||||
task.associatedJavaCompileTaskSources.from(javaTaskProvider.map { it.source })
|
task.associatedJavaCompileTaskSources.from(javaTaskProvider.map { it.source })
|
||||||
task.associatedJavaCompileTaskName.value(javaTaskProvider.name)
|
task.associatedJavaCompileTaskName.value(javaTaskProvider.name)
|
||||||
}
|
}
|
||||||
task.moduleName.value(providers.provider {
|
task.ownModuleName.value(providers.provider {
|
||||||
(compilation.kotlinOptions as? KotlinJvmOptions)?.moduleName ?: task.parentKotlinOptions.orNull?.moduleName
|
(compilation.kotlinOptions as? KotlinJvmOptions)?.moduleName ?: task.parentKotlinOptions.orNull?.moduleName
|
||||||
?: compilation.moduleName
|
?: compilation.ownModuleName
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user