Skip to content

Commit 59be77c

Browse files
authored
Merge pull request #647 from mgroth0/check_multi
apply ksp to multiplatform configs in multiplatform modules
2 parents 18dbbbf + af8c034 commit 59be77c

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

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

+12-4
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,27 @@ class ConvenienceSchemaGeneratorPlugin : Plugin<Project> {
3030
// configure it to depend on symbol-processor-all
3131
target.plugins.whenPluginAdded {
3232
if ("com.google.devtools.ksp" in this.javaClass.packageName) {
33+
val isMultiplatform =
34+
when {
35+
target.plugins.hasPlugin("org.jetbrains.kotlin.jvm") -> false
36+
target.plugins.hasPlugin("org.jetbrains.kotlin.multiplatform") -> true
37+
else -> throw Exception("Kotlin plugin must be applied first so we know whether to use multiplatform configurations or not")
38+
}
39+
val mainKspCfg = if (isMultiplatform) "kspJvm" else "ksp"
40+
val testKspCfg = if (isMultiplatform) "kspJvmTest" else "kspTest"
3341
try {
34-
target.configurations.getByName("ksp").dependencies.add(
42+
target.configurations.getByName(mainKspCfg).dependencies.add(
3543
target.dependencies.create("org.jetbrains.kotlinx.dataframe:symbol-processor-all:$preprocessorVersion")
3644
)
3745
} catch (e: UnknownConfigurationException) {
38-
target.logger.warn("Configuration 'ksp' not found. Please make sure the KSP plugin is applied.")
46+
target.logger.warn("Configuration '$mainKspCfg' not found. Please make sure the KSP plugin is applied.")
3947
}
4048
try {
41-
target.configurations.getByName("kspTest").dependencies.add(
49+
target.configurations.getByName(testKspCfg).dependencies.add(
4250
target.dependencies.create("org.jetbrains.kotlinx.dataframe:symbol-processor-all:$preprocessorVersion")
4351
)
4452
} catch (e: UnknownConfigurationException) {
45-
target.logger.warn("Configuration 'kspTest' not found. Please make sure the KSP plugin is applied.")
53+
target.logger.warn("Configuration '$testKspCfg' not found. Please make sure the KSP plugin is applied.")
4654
}
4755
target.logger.info("Added DataFrame dependency to the KSP plugin.")
4856
target.extensions.getByType<KspExtension>().arg("dataframe.resolutionDir", target.projectDir.absolutePath)

0 commit comments

Comments
 (0)