[NewIC] Fix build failure when enabling new IC in projects using Kapt
Originally, the classpath-snapshot output directory was:
1. <project>/build/kotlin/<task>/classpath-snapshot for KotlinCompile
2. <project>/build/tmp/kapt3/classpath-snapshot/<source-set> for
KaptGenerateStubsTask
In commit 1d1c6d5, we started using location 1 for both tasks for
consistency.
Around that time, commit 46cb490 had a merge conflict with the above
commit, but the conflict resolution was not correct yet:
- The property was set twice, causing a build failure.
- Location 2 was set for KaptGenerateStubsTask again.
This commit fixes both issues, so that:
- The property is set only once.
- Location 1 is used for both tasks.
Test: Added Kapt3IT.testSimpleWithIC_withClasspathSnapshot to prevent
regression
^KT-52187 Fixed
This commit is contained in:
committed by
nataliya.valtman
parent
74307ad434
commit
3321a1b4e2
+11
-1
@@ -283,10 +283,20 @@ open class Kapt3IT : Kapt3BaseIT() {
|
||||
@DisplayName("Kapt is working with incremental compilation")
|
||||
@GradleTest
|
||||
fun testSimpleWithIC(gradleVersion: GradleVersion) {
|
||||
doTestSimpleWithIC(gradleVersion)
|
||||
}
|
||||
|
||||
@DisplayName("Kapt is working with incremental compilation, when kotlin.incremental.useClasspathSnapshot=true")
|
||||
@GradleTest
|
||||
fun testSimpleWithIC_withClasspathSnapshot(gradleVersion: GradleVersion) {
|
||||
doTestSimpleWithIC(gradleVersion, useClasspathSnapshot = true)
|
||||
}
|
||||
|
||||
private fun doTestSimpleWithIC(gradleVersion: GradleVersion, useClasspathSnapshot: Boolean? = null) {
|
||||
project(
|
||||
"simple".withPrefix,
|
||||
gradleVersion,
|
||||
buildOptions = defaultBuildOptions.copy(incremental = true)
|
||||
buildOptions = defaultBuildOptions.copy(incremental = true, useGradleClasspathSnapshot = useClasspathSnapshot)
|
||||
) {
|
||||
build("clean", "build") {
|
||||
assertTasksExecuted(":kaptGenerateStubsKotlin", ":kaptKotlin", ":compileKotlin", ":compileJava")
|
||||
|
||||
-3
@@ -229,8 +229,6 @@ class Kapt3GradleSubplugin @Inject internal constructor(private val registry: To
|
||||
|
||||
private fun Kapt3SubpluginContext.getKaptIncrementalDataDir() = temporaryKaptDirectory("incrementalData")
|
||||
|
||||
private fun Kapt3SubpluginContext.getKaptClasspathSnapshotDir() = temporaryKaptDirectory("classpath-snapshot")
|
||||
|
||||
private fun Kapt3SubpluginContext.getKaptIncrementalAnnotationProcessingCache() = temporaryKaptDirectory("incApCache")
|
||||
|
||||
private fun Kapt3SubpluginContext.temporaryKaptDirectory(
|
||||
@@ -483,7 +481,6 @@ class Kapt3GradleSubplugin @Inject internal constructor(private val registry: To
|
||||
"${kotlinSourcesOutputDir.relativeTo(projectDir).path}/**"
|
||||
)
|
||||
it.kaptClasspath.from(kaptClasspathConfigurations)
|
||||
it.classpathSnapshotProperties.classpathSnapshotDir.fileValue(getKaptClasspathSnapshotDir())
|
||||
}
|
||||
|
||||
taskConfig.execute(kaptTaskProvider)
|
||||
|
||||
Reference in New Issue
Block a user