Skip to content

Commit e15cb54

Browse files
committed
add option to prevent Gradle plugin from adding dependency on KSP
We add plugin automatically for better onboarding experience, but it makes project depend on some specific KSP version. KSP complains when people use it with different version of compiler: ksp-1.9.0-1.0.12 is too old for kotlin-1.9.21. Please upgrade ksp or downgrade kotlin-gradle-plugin to 1.9.0. In dataframe project itself we always need to update Kotlin version in two steps. With this change (and one more PR later) it won't be necessary anymore Still, it's ok to use preprocessor built for 1.9.0 with KSP 1.9.21. That's why we need an option for people to decide version of KSP they need in their project. People will be able to use our preprocessor built for older versions of KSP API most of the time without problems thanks to backward compatibility
1 parent a2eb000 commit e15cb54

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

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

+18-3
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,29 @@ package org.jetbrains.dataframe.gradle
33
import com.google.devtools.ksp.gradle.KspExtension
44
import org.gradle.api.Plugin
55
import org.gradle.api.Project
6-
import org.gradle.kotlin.dsl.getByType
6+
import org.gradle.kotlin.dsl.findByType
77
import java.util.*
88

99
@Suppress("unused")
1010
class ConvenienceSchemaGeneratorPlugin : Plugin<Project> {
1111
override fun apply(target: Project) {
12-
target.plugins.apply(KspPluginApplier::class.java)
12+
val name = "kotlin.dataframe.add.ksp"
13+
val property = target.findProperty(name)?.toString()
14+
var addKsp = true
15+
16+
if (property != null) {
17+
if (property.equals("true", ignoreCase = true) || property.equals("false", ignoreCase = true)) {
18+
addKsp = property.toBoolean()
19+
} else {
20+
target.logger.warn("Invalid value '$property' for '$name' property. Defaulting to '$addKsp'. Please use 'true' or 'false'.")
21+
}
22+
}
23+
if (addKsp) {
24+
target.plugins.apply(KspPluginApplier::class.java)
25+
}
26+
target.afterEvaluate {
27+
target.extensions.findByType<KspExtension>()?.arg("dataframe.resolutionDir", target.projectDir.absolutePath)
28+
}
1329
target.plugins.apply(SchemaGeneratorPlugin::class.java)
1430
}
1531
}
@@ -31,6 +47,5 @@ internal class KspPluginApplier : Plugin<Project> {
3147
target.configurations.getByName("ksp").dependencies.add(
3248
target.dependencies.create("org.jetbrains.kotlinx.dataframe:symbol-processor-all:$preprocessorVersion")
3349
)
34-
target.extensions.getByType<KspExtension>().arg("dataframe.resolutionDir", target.projectDir.absolutePath)
3550
}
3651
}

0 commit comments

Comments
 (0)