aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTing-Yuan Huang <laszio@google.com>2022-12-08 12:01:51 -0800
committerlaszio <ting-yuan@users.noreply.github.com>2022-12-08 12:41:19 -0800
commit8733ad377260becd812c6640eaa1290b1d678d92 (patch)
tree61cc0bd72ee3ab019e23265870f7480c991ad4d7
parente488d76f7c8145728d62f9858ff6aa886fa6b8eb (diff)
downloadksp-8733ad377260becd812c6640eaa1290b1d678d92.tar.gz
Do not pass lambda to task actions
that would disable execution optimization. See below for details: https://docs.gradle.org/7.2/userguide/validation_problems.html#implementation_unknown
-rw-r--r--gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/KspSubplugin.kt11
-rw-r--r--integration-tests/src/test/kotlin/com/google/devtools/ksp/test/KMPImplementedIT.kt14
2 files changed, 22 insertions, 3 deletions
diff --git a/gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/KspSubplugin.kt b/gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/KspSubplugin.kt
index fa74d79a..0cd7e958 100644
--- a/gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/KspSubplugin.kt
+++ b/gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/KspSubplugin.kt
@@ -18,6 +18,7 @@
package com.google.devtools.ksp.gradle
import com.google.devtools.ksp.gradle.model.builder.KspModelBuilder
+import org.gradle.api.Action
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.UnknownTaskException
@@ -422,9 +423,13 @@ class KspGradleSubplugin @Inject internal constructor(private val registry: Tool
kspTask.compilerOptions.freeCompilerArgs.value(
kspOptions + kotlinCompileTask.compilerOptions.freeCompilerArgs.get()
)
- kspTask.doFirst {
- kspOutputDir.deleteRecursively()
- }
+ // Cannot use lambda; See below for details.
+ // https://docs.gradle.org/7.2/userguide/validation_problems.html#implementation_unknown
+ kspTask.doFirst(object : Action<Task> {
+ override fun execute(t: Task) {
+ kspOutputDir.deleteRecursively()
+ }
+ })
}
}
}
diff --git a/integration-tests/src/test/kotlin/com/google/devtools/ksp/test/KMPImplementedIT.kt b/integration-tests/src/test/kotlin/com/google/devtools/ksp/test/KMPImplementedIT.kt
index 3cd19de1..cee259e4 100644
--- a/integration-tests/src/test/kotlin/com/google/devtools/ksp/test/KMPImplementedIT.kt
+++ b/integration-tests/src/test/kotlin/com/google/devtools/ksp/test/KMPImplementedIT.kt
@@ -32,6 +32,13 @@ class KMPImplementedIT {
Assert.assertTrue(artifact.readBytes().size > 0)
}
+ private fun checkExecutionOptimizations(log: String) {
+ Assert.assertFalse(
+ "Execution optimizations have been disabled",
+ log.contains("Execution optimizations have been disabled")
+ )
+ }
+
@Test
fun testJvm() {
Assume.assumeFalse(System.getProperty("os.name").startsWith("Windows", ignoreCase = true))
@@ -52,6 +59,7 @@ class KMPImplementedIT {
Assert.assertFalse(it.output.contains("kotlin scripting plugin:"))
Assert.assertTrue(it.output.contains("w: [ksp] platforms: [JVM"))
Assert.assertTrue(it.output.contains("w: [ksp] List has superTypes: true"))
+ checkExecutionOptimizations(it.output)
}
}
@@ -98,6 +106,7 @@ class KMPImplementedIT {
Assert.assertFalse(it.output.contains("kotlin scripting plugin:"))
Assert.assertTrue(it.output.contains("w: [ksp] platforms: [JS"))
Assert.assertTrue(it.output.contains("w: [ksp] List has superTypes: true"))
+ checkExecutionOptimizations(it.output)
}
}
@@ -156,6 +165,7 @@ class KMPImplementedIT {
)
Assert.assertFalse(it.output.contains("kotlin scripting plugin:"))
Assert.assertTrue(it.output.contains("w: [ksp] platforms: [Native"))
+ checkExecutionOptimizations(it.output)
}
}
@@ -193,6 +203,7 @@ class KMPImplementedIT {
Assert.assertTrue(it.output.contains("w: [ksp] List has superTypes: true"))
Assert.assertTrue(File(genDir, "Main_dot_kt.kt").exists())
Assert.assertTrue(File(genDir, "ToBeRemoved_dot_kt.kt").exists())
+ checkExecutionOptimizations(it.output)
}
File(project.root, "workload-linuxX64/src/linuxX64Main/kotlin/ToBeRemoved.kt").delete()
@@ -206,6 +217,7 @@ class KMPImplementedIT {
verifyKexe("workload-linuxX64/build/bin/linuxX64/releaseExecutable/workload-linuxX64.kexe")
Assert.assertTrue(File(genDir, "Main_dot_kt.kt").exists())
Assert.assertFalse(File(genDir, "ToBeRemoved_dot_kt.kt").exists())
+ checkExecutionOptimizations(it.output)
}
}
@@ -313,6 +325,7 @@ class KMPImplementedIT {
output.contains(it)
}
)
+ checkExecutionOptimizations(output)
}
// KotlinNative doesn't support configuration cache yet.
@@ -327,6 +340,7 @@ class KMPImplementedIT {
}
)
verifyAll(this)
+ checkExecutionOptimizations(output)
}
}
}