@@ -5,22 +5,33 @@ import org.gradle.api.Plugin
5
5
import org.gradle.api.Project
6
6
import org.gradle.api.artifacts.UnknownConfigurationException
7
7
import org.gradle.kotlin.dsl.getByType
8
- import org.jetbrains.kotlin.gradle.plugin.extraProperties
9
8
import java.util.Properties
10
9
11
10
@Suppress(" unused" )
12
11
class 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
+
13
25
override fun apply (target : Project ) {
14
- val name = " kotlin.dataframe.add.ksp"
15
- val property = target.findProperty(name)?.toString()
26
+ val property = target.findProperty(PROP_ADD_KSP )?.toString()
16
27
var addKsp = true
17
28
18
29
if (property != null ) {
19
30
if (property.equals(" true" , ignoreCase = true ) || property.equals(" false" , ignoreCase = true )) {
20
31
addKsp = property.toBoolean()
21
32
} else {
22
33
target.logger.warn(
23
- " 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'." ,
24
35
)
25
36
}
26
37
}
@@ -47,23 +58,11 @@ class ConvenienceSchemaGeneratorPlugin : Plugin<Project> {
47
58
}
48
59
}
49
60
}
50
- val customConfigsProp = " kotlin.dataframe.ksp.configs"
51
- var overriddenConfigs =
52
- target.properties.get(customConfigsProp)?.let { (it as String )}?.split(" ," )
53
- if (overriddenConfigs != null ) {
54
- overriddenConfigs =
55
- target.extraProperties.get(customConfigsProp)?.let { (it as String )}?.split(" ," )
56
- } else {
57
- if (customConfigsProp in target.extraProperties.properties) {
58
- target.logger.warn(
59
- " `$customConfigsProp ` set as both a regular and an extra property. Only the regular property value is used." ,
60
- )
61
- }
62
- }
61
+ val overriddenConfigs = target.findProperty(PROP_KSP_CONFIGS )?.let { (it as String ) }?.split(" ," )
63
62
val configs = when {
64
63
overriddenConfigs != null -> overriddenConfigs
65
- isMultiplatform -> listOf (" kspJvm" ," kspJvmTest" )
66
- else -> listOf (" ksp" ," kspTest" )
64
+ isMultiplatform -> listOf (" kspJvm" , " kspJvmTest" )
65
+ else -> listOf (" ksp" , " kspTest" )
67
66
}
68
67
configs.forEach { cfg ->
69
68
try {
0 commit comments