@@ -3,6 +3,7 @@ package org.jetbrains.dataframe.gradle
3
3
import com.google.devtools.ksp.gradle.KspExtension
4
4
import org.gradle.api.Plugin
5
5
import org.gradle.api.Project
6
+ import org.gradle.api.artifacts.UnknownConfigurationException
6
7
import org.gradle.kotlin.dsl.findByType
7
8
import java.util.*
8
9
@@ -20,9 +21,33 @@ class ConvenienceSchemaGeneratorPlugin : Plugin<Project> {
20
21
target.logger.warn(" Invalid value '$property ' for '$name ' property. Defaulting to '$addKsp '. Please use 'true' or 'false'." )
21
22
}
22
23
}
24
+
25
+ val properties = Properties ()
26
+ properties.load(javaClass.getResourceAsStream(" plugin.properties" ))
27
+ val preprocessorVersion = properties.getProperty(" PREPROCESSOR_VERSION" )
28
+
29
+ // regardless whether we add KSP or the user adds it, when it's added,
30
+ // configure it to depend on symbol-processor-all
31
+ target.plugins.whenPluginAdded {
32
+ if (" com.google.devtools.ksp" in this .javaClass.packageName) {
33
+ target.configurations.getByName(" ksp" ).dependencies.add(
34
+ target.dependencies.create(" org.jetbrains.kotlinx.dataframe:symbol-processor-all:$preprocessorVersion " )
35
+ )
36
+ target.logger.info(" Added DataFrame dependency to the KSP plugin." )
37
+ }
38
+ }
39
+
23
40
if (addKsp) {
24
- target.plugins.apply (KspPluginApplier ::class .java)
41
+ target.plugins.apply (KspPluginApplierAndConfigurer ::class .java)
42
+ } else {
43
+ target.logger.warn(
44
+ " Plugin 'org.jetbrains.kotlinx.dataframe' comes bundled with its own version of KSP which is " +
45
+ " currently disabled as 'kotlin.dataframe.add.ksp' is set to 'false' in a 'properties' file. " +
46
+ " Either set 'kotlin.dataframe.add.ksp' to 'true' or add the plugin 'com.google.devtools.ksp' " +
47
+ " manually."
48
+ )
25
49
}
50
+
26
51
target.afterEvaluate {
27
52
target.extensions.findByType<KspExtension >()?.arg(" dataframe.resolutionDir" , target.projectDir.absolutePath)
28
53
}
@@ -38,14 +63,13 @@ class DeprecatingSchemaGeneratorPlugin : Plugin<Project> {
38
63
}
39
64
}
40
65
41
- internal class KspPluginApplier : Plugin <Project > {
66
+ /* *
67
+ * Applies and configures the KSP plugin in the target project.
68
+ */
69
+ internal class KspPluginApplierAndConfigurer : Plugin <Project > {
42
70
override fun apply (target : Project ) {
43
71
val properties = Properties ()
44
72
properties.load(javaClass.getResourceAsStream(" plugin.properties" ))
45
- val preprocessorVersion = properties.getProperty(" PREPROCESSOR_VERSION" )
46
73
target.plugins.apply (" com.google.devtools.ksp" )
47
- target.configurations.getByName(" ksp" ).dependencies.add(
48
- target.dependencies.create(" org.jetbrains.kotlinx.dataframe:symbol-processor-all:$preprocessorVersion " )
49
- )
50
74
}
51
75
}
0 commit comments