@@ -9,17 +9,29 @@ import java.util.Properties
99
1010@Suppress(" unused" )
1111class ConvenienceSchemaGeneratorPlugin : Plugin <Project > {
12+ companion object {
13+ /* *
14+ * (boolean, default `true`) whether to add KSP plugin
15+ */
16+ const val PROP_ADD_KSP = " kotlin.dataframe.add.ksp"
17+
18+ /* *
19+ * (string, default `null`) comma-delimited list of configurations to add KSP processing to.
20+ * Defaults to guessing configurations based on which kotlin plugin is applied (jvm or multiplatform)
21+ */
22+ const val PROP_KSP_CONFIGS = " kotlin.dataframe.ksp.configs"
23+ }
24+
1225 override fun apply (target : Project ) {
13- val name = " kotlin.dataframe.add.ksp"
14- val property = target.findProperty(name)?.toString()
26+ val property = target.findProperty(PROP_ADD_KSP )?.toString()
1527 var addKsp = true
1628
1729 if (property != null ) {
1830 if (property.equals(" true" , ignoreCase = true ) || property.equals(" false" , ignoreCase = true )) {
1931 addKsp = property.toBoolean()
2032 } else {
2133 target.logger.warn(
22- " Invalid value '$property ' for '$name ' property. Defaulting to '$addKsp '. Please use 'true' or 'false'." ,
34+ " Invalid value '$property ' for '$PROP_ADD_KSP ' property. Defaulting to '$addKsp '. Please use 'true' or 'false'." ,
2335 )
2436 }
2537 }
@@ -32,7 +44,7 @@ class ConvenienceSchemaGeneratorPlugin : Plugin<Project> {
3244 // configure it to depend on symbol-processor-all
3345 target.plugins.whenPluginAdded {
3446 if (" com.google.devtools.ksp" in this .javaClass.packageName) {
35- val isMultiplatform =
47+ val isMultiplatform by lazy {
3648 when {
3749 target.plugins.hasPlugin(" org.jetbrains.kotlin.jvm" ) -> false
3850
@@ -45,29 +57,28 @@ class ConvenienceSchemaGeneratorPlugin : Plugin<Project> {
4557 false
4658 }
4759 }
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- )
6060 }
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- )
61+ val overriddenConfigs = target.findProperty(PROP_KSP_CONFIGS )
62+ ?.let { (it as String ) }
63+ ?.split(" ," )
64+ ?.map { it.trim() }
65+ val configs = when {
66+ overriddenConfigs != null -> overriddenConfigs
67+ isMultiplatform -> listOf (" kspJvm" , " kspJvmTest" )
68+ else -> listOf (" ksp" , " kspTest" )
69+ }
70+ configs.forEach { cfg ->
71+ try {
72+ target.configurations.getByName(cfg).dependencies.add(
73+ target.dependencies.create(
74+ " org.jetbrains.kotlinx.dataframe:symbol-processor-all:$preprocessorVersion " ,
75+ ),
76+ )
77+ } catch (e: UnknownConfigurationException ) {
78+ target.logger.warn(
79+ " Configuration '$cfg ' not found. Please make sure the KSP plugin is applied." ,
80+ )
81+ }
7182 }
7283 target.logger.info(" Added DataFrame dependency to the KSP plugin." )
7384 target.extensions.getByType<KspExtension >().arg(
0 commit comments