Skip to content

Commit 77e88a1

Browse files
committed
allow applying ksp to custom configs
1 parent b5073de commit 77e88a1

File tree

1 file changed

+21
-23
lines changed

1 file changed

+21
-23
lines changed

plugins/dataframe-gradle-plugin/src/main/kotlin/org/jetbrains/dataframe/gradle/ConvenienceSchemaGeneratorPlugin.kt

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import org.gradle.api.Plugin
55
import org.gradle.api.Project
66
import org.gradle.api.artifacts.UnknownConfigurationException
77
import org.gradle.kotlin.dsl.getByType
8+
import org.jetbrains.kotlin.gradle.plugin.extraProperties
89
import java.util.Properties
910

1011
@Suppress("unused")
@@ -32,7 +33,7 @@ class ConvenienceSchemaGeneratorPlugin : Plugin<Project> {
3233
// configure it to depend on symbol-processor-all
3334
target.plugins.whenPluginAdded {
3435
if ("com.google.devtools.ksp" in this.javaClass.packageName) {
35-
val isMultiplatform =
36+
val isMultiplatform by lazy {
3637
when {
3738
target.plugins.hasPlugin("org.jetbrains.kotlin.jvm") -> false
3839

@@ -45,29 +46,26 @@ class ConvenienceSchemaGeneratorPlugin : Plugin<Project> {
4546
false
4647
}
4748
}
48-
val mainKspCfg = if (isMultiplatform) "kspJvm" else "ksp"
49-
val testKspCfg = if (isMultiplatform) "kspJvmTest" else "kspTest"
50-
try {
51-
target.configurations.getByName(mainKspCfg).dependencies.add(
52-
target.dependencies.create(
53-
"org.jetbrains.kotlinx.dataframe:symbol-processor-all:$preprocessorVersion",
54-
),
55-
)
56-
} catch (e: UnknownConfigurationException) {
57-
target.logger.warn(
58-
"Configuration '$mainKspCfg' not found. Please make sure the KSP plugin is applied.",
59-
)
6049
}
61-
try {
62-
target.configurations.getByName(testKspCfg).dependencies.add(
63-
target.dependencies.create(
64-
"org.jetbrains.kotlinx.dataframe:symbol-processor-all:$preprocessorVersion",
65-
),
66-
)
67-
} catch (e: UnknownConfigurationException) {
68-
target.logger.warn(
69-
"Configuration '$testKspCfg' not found. Please make sure the KSP plugin is applied.",
70-
)
50+
val overriddenConfigs =
51+
target.properties.get("kotlin.dataframe.ksp.configs")?.let { (it as String)}?.split(",")
52+
val configs = when {
53+
overriddenConfigs != null -> overriddenConfigs
54+
isMultiplatform -> listOf("kspJvm","kspJvmTest")
55+
else -> listOf("ksp","kspTest")
56+
}
57+
configs.forEach { cfg ->
58+
try {
59+
target.configurations.getByName(cfg).dependencies.add(
60+
target.dependencies.create(
61+
"org.jetbrains.kotlinx.dataframe:symbol-processor-all:$preprocessorVersion",
62+
),
63+
)
64+
} catch (e: UnknownConfigurationException) {
65+
target.logger.warn(
66+
"Configuration '$cfg' not found. Please make sure the KSP plugin is applied.",
67+
)
68+
}
7169
}
7270
target.logger.info("Added DataFrame dependency to the KSP plugin.")
7371
target.extensions.getByType<KspExtension>().arg(

0 commit comments

Comments
 (0)