aboutsummaryrefslogtreecommitdiff
path: root/gradle-plugin
diff options
context:
space:
mode:
authorTing-Yuan Huang <laszio@google.com>2021-12-06 21:09:36 -0800
committerlaszio <ting-yuan@users.noreply.github.com>2021-12-07 00:30:56 -0800
commit5e4734b6c3a3b184a28b8f8fdf596603edd99cb6 (patch)
tree56672d1756c3844bc8d85f49ba78346299e99510 /gradle-plugin
parent89446575bea4daf46e31e6cba86d77746bcb2b7b (diff)
downloadksp-5e4734b6c3a3b184a28b8f8fdf596603edd99cb6.tar.gz
Map "kspJsLegacy" and "kspJsIr" to "kspJs"
When js(BOTH) is used, target "jsLegacy" and "jsIr" are created. Both targets share the same source set. Therefore configurations other than main compilation are shared. E.g., "kspJsTest". For simplicity and consistency, let's not distinguish the two targets when creating and specifying KSP configurations.
Diffstat (limited to 'gradle-plugin')
-rw-r--r--gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/KspConfigurations.kt15
1 files changed, 14 insertions, 1 deletions
diff --git a/gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/KspConfigurations.kt b/gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/KspConfigurations.kt
index ca7582e5..e4325894 100644
--- a/gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/KspConfigurations.kt
+++ b/gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/KspConfigurations.kt
@@ -57,7 +57,20 @@ class KspConfigurations(private val project: Project) {
val isMain = compilation.name == KotlinCompilation.MAIN_COMPILATION_NAME
val isDefault = sourceSet.name == compilation.defaultSourceSetName
// Note: on single-platform, target name is conveniently set to "".
- val name = if (isMain && isDefault) compilation.target.name else sourceSet.name
+ val name = if (isMain && isDefault) {
+ // For js(IR), js(LEGACY), the target "js" is created.
+ //
+ // When js(BOTH) is used, target "jsLegacy" and "jsIr" are created.
+ // Both targets share the same source set. Therefore configurations other than main compilation
+ // are shared. E.g., "kspJsTest".
+ // For simplicity and consistency, let's not distinguish them.
+ when (val targetName = compilation.target.name) {
+ "jsLegacy", "jsIr" -> "js"
+ else -> targetName
+ }
+ } else {
+ sourceSet.name
+ }
return configurationNameOf(PREFIX, name)
}